Outlook 2007 to Attach a File in an Existing Message

  • Thread starter Thread starter Gary Petersen
  • Start date Start date
G

Gary Petersen

I'd like to create a macro in Outlook 2007 to attach a specific file to an
open message. I've been searching and have the following bit of code, but it
creates a new blank message with the file attached. I'm close, but am not
sure how to get this to work in the existing open message.

Here's the code I've got so far.

Sub Attach_MyFile()
Set NewItem = Application.CreateItem(0)
NewItem.Attachments.Add "\\path\filename"
NewItem.Display
End Sub

\\path\filename would be changed to the specific file I want to attach.

It works just fine, but creates a new message. What would I change to add
this file attachment to the existing open message? In other words, what is
the command that would be like Application.EditItem(0)? :-)

Thanks for any help. I do appreciate it.
 
Sub Attach_MyFile()
Set NewItem = Application.ActiveInspector.CurrentItem
NewItem.Attachments.Add "\\path\filename"
End Sub

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Thank you, Dmitry. I tried it on my home laptop and it worked perfectly.
I'm sure that will get me fixed up tomorrow on my work laptop. I really
appreciate the help.
--
Gary Petersen



Dmitry Streblechenko said:
Sub Attach_MyFile()
Set NewItem = Application.ActiveInspector.CurrentItem
NewItem.Attachments.Add "\\path\filename"
End Sub

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Back
Top