Get Sender of a message

  • Thread starter Thread starter Marcus O. M. Grabe
  • Start date Start date
M

Marcus O. M. Grabe

Hi all,

I normally do programming VBA within Excel or Word or just VB itself,
so I do not know the objects in Outlook.

How can I get the sender of a message
a) when the message is opened
b) when the message is just marked is the list of msgs?

Thanks for any help,

Marcus.
 
In Outlook 2003, you can use the MailItem.SenderEmailAddress, but note that it's subject to security prompts.

In earlier versions, there is no Outlook property that returns the sender's email address. You can either use CDO (or Redemption to avoid security prompts -- http://www.dimastr.com/redemption/) to get the From address or use Outlook to get the Reply To address. Sample code at http://www.outlookcode.com/d/code/getsenderaddy.htm

To get the SMTP address from an Exchange sender or recipient, use CDO or Redemption and the PR_EMAIL (&H39FE001E) MAPI property to obtain the SMTP address from the AddressEntry object. See http://www.outlookcode.com/d/code/getsenderaddy.htm#redemption and http://www.cdolive.com/cdo5.htm#EMailAddressOfSender for examples.
a) when the message is opened
Application.ActiveInspector.CurrentItem

b) when the message is just marked is the list of msgs?

Application.ActiveExplorer.Selection(1)
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top