Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read sender's email address from MS Outlook mail

Tags:

c#

outlook

I am using below code to read incoming mails from MS Outlook 2010 -

public static void outLookApp_NewMailEx(string EntryIDCollection)
{                
    NameSpace _nameSpace;
    ApplicationClass _app;
    _app = new ApplicationClass();
    _nameSpace = _app.GetNamespace("MAPI");
    object o = _nameSpace.GetItemFromID(EntryIDCollection);
    MailItem Item = (MailItem)o;
    string HTMLbpdyTest = Item.HTMLBody;
    string CreationTime = Convert.ToString(Item.CreationTime);
    string strEmailSenderEmailId = Convert.ToString(Item.SenderEmailAddress);
    string strEmailSenderName = Item.SenderName;
    string Subject = Item.Subject;
} 

How can I get sender's mail id. I tried Item.SenderEmailAddress but its not giving me the sender's email id. It is giving me something like this -

/O=EXG5/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=TEST35345
like image 473
user2318170 Avatar asked May 31 '13 09:05

user2318170


People also ask

Can you extract email addresses from Outlook?

On the toolbar, select Manage > Export contacts. Choose to export all contacts or only contacts from a specific folder, and then select Export. At the bottom of the page, select Save to save "contacts. csv" in your default Downloads folder.


1 Answers

The address returned now is an (X.400) Exchange address. Please take a look at this MSDN article on how to retrieve the corresponding SMTP address.

like image 100
jao Avatar answered Nov 05 '22 10:11

jao