Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
524 views
in Technique[技术] by (71.8m points)

c# - Read sender's email address from MS Outlook mail

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...