Thursday, 22 March 2018

Add attachments to an email object Excel VBA | Email automation | Insert Attachments VBA


Sometimes when you work on bulk emailing using VBA, you have to insert attachments to the email.

In such cases, you can use the Add method under mail item to insert attachment to the email object.

Please refer the code below.


Sub AddAttachment() Dim MailItem As Outlook.MailItem Dim MailAttachments As Outlook.Attachments Set MailItem = Application.CreateItem(olMailItem) mailItem.Attachments.Add "C:\Documents\abcd.xlsx" mailItem.Display End Sub