I would like to get the active opened MailItem (whether it's a new mail or a received mail). I need to add some content to that mail when the user runs my macro. I'm using Outlook 2003 and VBA.
I found this: How do you get a reference to the mail item in the current open window in Outlook using VBA? It doesn't work however because TypeName(Application.ActiveWindow)
is set to nothing. I also tried Set Mail = Application.ActiveInspector.currentItem
but it doesn't work either.
There must be something I don't understand about the ActiveInspector thing.
As requested, this is the procedure/macro located in a dedicated module, called when the user click on a menu-button added in the Application_Startup()
method:
Sub myMacro()
Dim NewMail As Outlook.MailItem
Set NewMail = Application.ActiveInspector.currentItem
End Sub