Add Attachment to Outlook 365 - TechRepublic
Question
February 12, 2016 at 05:55 PM
clay.sanker

Add Attachment to Outlook 365

by clay.sanker . Updated 10 years, 4 months ago

I am very new to macro’s and VBScripts. I’m trying to come up with a macro that will attach specific files to a new email that is already opened or a reply when the macro is executed. Currently I’m using the below script I found but it opens a new email. I just want it to attach a file specified in the macro but not open new. Thank you in advance for your help!

Sub ExistingMessageWithAttachment2()
Const olFormatHTML = 2
Dim objOutlook : Set objOutlook = CreateObject(“Outlook.Application”)
Dim olMailItem
Dim objMailItem : Set objMailItem = objOutlook.CreateItem(olMailItem)

objMailItem.To = strTO
objMailItem.CC = strCC
objMailItem.Subject = strSUBJECT
objMailItem.BodyFormat = olFormatHTML
objMailItem.HTMLBody = “Test Msg” & “
” & MySig
Set objOutlookAttach = objMailItem.Attachments.Add (“C:\Temp\Test.pdf”)
objMailItem.Display
End sub

This discussion is locked

All Comments