How to retrieve sender’s email address if sender belongs to exchan

N

Neetu

The SenderEmailAddress property of the MailItem object is supposed to return
the email address. And it does if the email comes from an internet sender.
If the email sender a user of Microsoft Exchange, you get a weird formatted
email address like this
/O=PROTEANS EXCHANGE/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=VIPIN.HARI

How to determine sender’s smtp address in Outlook 2007 without
Redemtion/CDO. I have tried it by using Extended MAPI
(PR_SENDER_EMAIL_ADDRESS) from
http://www.outlookcode.com/codedetail.aspx?id=1112. But here also I’m getting
the email address in distinguished name format.
Please help me out to obtain the email address like (e-mail address removed)
 
N

Neetu

I got the solution.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3367576&SiteID=1

if (vrefMailItem.SenderEmailType == "EX" //Exchange user
{
Application lobjApplication = Marshal.GetActiveObject("Outlook.Application")
as Application;
Recipient lobjReceipient =
lobjApplication.Session.CreateRecipient(vrefMailItem.SenderEmailAddress);
ExchangeUser lobjExchangeUser = lobjReceipient.AddressEntry.GetExchangeUser();
lobjMail.SenderEmailID = lobjExchangeUser.PrimarySmtpAddress;
}
else //SMTP
{
lobjMail.SenderEmailID = vrefMailItem.SenderEmailAddress;
}

This approach is only available for Outlook 2007. For Outlook 2003 or older
you should use CDO, Redemption or Extended MAPI. Refer
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1463875&SiteID=1
for that.
 

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