Macro to get name of attachments in a message





JJ said:
Has anyone got a sample macro to do this?

Here we are (extracted from my macro for saving attachments to disk and
removing them from the message):

Sub Attachments()
Dim myOlApp As Outlook.Application
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
If Not TypeName(myInspector) = "Nothing" Then
If TypeName(myInspector.CurrentItem) = "MailItem" Then
Set myItem = myInspector.CurrentItem
Set myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then
For i = myAttachments.Count To 1 Step -1
MsgBox "Name of attachment is " & _
Next i
End If
MsgBox "The current selection is no message."
End If
End If
'free variables
Set myOlApp = Nothing
Set myInspector = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
End Sub

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question