Problem Retrieving To/From email Addresses

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!
 
S

Sue Mosher [MVP-Outlook]

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
 

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