List attachments

G

Guest

Outlook 2003. Could anyone point me in the direction of some code that will
list the names of any attachments after the text of the email (either
automatically or when the user "runs" the code.
 
K

Ken Slovak - [MVP - Outlook]

No, Attachment Options is just for setting the registry key for blocked
attachments, it has nothing to do with what attachments are in an email.

The OP doesn't mention where the code is going to run, which is important.
If say it's running as a VBA macro that's run from a button on a toolbar on
a selected item:

Sub AttachmentsList()
Dim oMail As Outlook.MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment
dim strAttach As String

Set oMail = Application.ActiveExplorer.Selection.Item(1)
Set colAttach = oMail.Attachments
For Each oAttach In colAttachments
strAttach = strAttach & vbCRLF & oAttach.DisplayName
Next

oMail.Body = oMail.Body & strAttach
oMail.Save
End Sub

That would write, one per line, a list of all attachment display names at
the end of the message body into that message. The message would be the one
currently selected in the folder view. No error checking in that sample,
that's an exercise for the reader.
 
H

Hollis Paul [MVP - Outlook]

Ken Slovak - [MVP - said:
The OP doesn't mention where the code is going to run, which is important.
If say it's running as a VBA macro that's run from a button on a toolbar on
a selected item:
Thanks, Ken. I guess I have never looked at what that add-in does.
 

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

Top