Outlook 2007 to Attach a File in an Existing Message

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.
 
D

Dmitry Streblechenko

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
-
 
G

Gary Petersen

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
-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top