Attach a File to a Mail Item

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

This topic shows a procedure that attaches a spreadsheet file to a mail item. The procedure, AddAttachment, assumes that the specified spreadsheet, Q496.xlsx, exists in the specified path, D:\Documents. AddAttachment creates a new mail message, attaches Q496.xlsx to the mail message, assigns the attachment a descriptive caption, and displays the mail message with this attachment.

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
Show: