Outlook 365 Macro - TechRepublic
Question
February 16, 2016 at 09:41 PM
clay.sanker

Outlook 365 Macro

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

I’m trying to create a macro in Outlook 365 that will attach specific docs to an open email(either new or a reply). I’ve found various macros that will do that but they all start a new emails as opposed to attaching to one I alreay have opened. I have the below script that I’ve tried to make work but it too creates a new email. All attachments are either PDF or Word format. I’m new to macros in Outlook and would appreciate any help you can give.

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 = “”

Set objOutlookAttach = objMailItem.Attachments.Add(“P:\Telecom\Avaya\Manuals\9611 user guide.pdf”)
Set objOutlookAttach = objMailItem.Attachments.Add(“P:\Telecom\Avaya\Manuals\Avaya_IP_Imp_Guide.pdf”)
objMailItem.Display
End Sub

This discussion is locked

All Comments