Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook/VBA

Status
Not open for further replies.

rpthomas

Programmer
Feb 2, 2002
7
US
I am trying to get the "AttachmentAdd" event to fire after adding an attachment to a new mail message. Can someone please tell me what I'm doing wrong?

Here is my code which resides in the "ThisOutlookSession" module:

Private WithEvents objMailItem As Outlook.MailItem

Private Sub Application_Startup()
Dim objMailItem As Outlook.MailItem
End Sub

Private Sub objMailItem_AttachmentAdd(ByVal Attachment As Attachment)
MsgBox "test"
End Sub

When I add an attachment this event does not fire.

Thanks
Roland Thomas
rpthomas@debevoise.com
 
I think you need a reference to the currently used mail item. I may be wrong but I believe as you have coded the above you are setting a reference to one specific mailitem. You want to set a reference to the one created when you create a new message using Outlook.

Sorry this is so general. Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top