Problem Retrieving To/From email Addresses

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on a small application that takes email from Outlook 2003 and
exports the senders email address, the recipients email address, subject and
body of a mail item into a flat text file.
Everything is working great, with a small caveat...
I cannot seem to retrieve the email address of the sender if they sent the
mail through Exchange. Likewise, I cannot retrieve the recipients email
address. All I get is the users full name in Active Directory.
For example, if the recipient of the mail was (e-mail address removed), and I
try this:
writer.WriteLine("To: " + mail.To)
I will get "John Smith" as the output string. I really need the email
address though!
The same goes for the "SenderEmailAddress" function.
Everything is fine otherwise when the mail is to/from someone outside the
company.

Is there a way to solve this problem without having to get into looking up
things in the address book?

Thanks a bunch!
 
SenderEmailAddress should give you the X.400 address of an Exchange user. Not terribly useful to most scenarios. 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.


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

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