Attachment Object (Outlook)
Published: July 16, 2012
Represents a document or link to a document contained in an Outlook item.
The following Visual Basic for Applications (VBA) example creates a new mail message, attaches Q496.xlsx as an attachment (not a link), assigns the attachment a descriptive caption, and displays the mail message with this attachment. This example assumes that the specified spreadsheet, Q496.xlsx, exists in the specified path, D:\Documents.
Sub AddAttachment() Dim myItem As Outlook.MailItem Dim myAttachments As Outlook.Attachments Set myItem = Application.CreateItem(olMailItem) Set myAttachments = myItem.Attachments myAttachments.Add "D:\Documents\Q496.xlsx", _ olByValue, 1, "4th Quarter 1996 Results Chart" myItem.Display End Sub