简体   繁体   中英

How to get the email address from MS outlook 2010?

This is the code I am using to retrieve the MS outlook mail -

                NameSpace _nameSpace;
                ApplicationClass _app;
                _app = new ApplicationClass();
                _nameSpace = _app.GetNamespace("MAPI");
                object o = _nameSpace.GetItemFromID(EntryIDCollection);
                MailItem Item = (MailItem)o;
                string HTMLbpdyTest = Item.HTMLBody;
                CreationTime = Convert.ToString(Item.CreationTime);

                Outlook.Recipients olRecipients = default(Outlook.Recipients);
                olRecipients = Item.Recipients;
                string strCcEmails = string.Empty;
                foreach (Outlook.Recipient olRecipient in Item.Recipients)
                { 
                  if (olRecipient.Type == Outlook.OlMailRecipientType.olCC)
                  {
                   strCcEmails = olRecipient.Address;
                  }
                }

While retrieving CC email address using MAPI from MS outlook 2010 its giving the output in this format -

strCcEmails = /O=EXG5/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=Test88067

How to get the exact email address?

使用Recipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress (省略错误/空检查)。

Try the code from http://msdn.microsoft.com/en-us/library/office/ff868695.aspx

Specifically:

Outlook.PropertyAccessor pa = olRecipient.PropertyAccessor; 
string smtpAddress = pa.GetProperty(PR_SMTP_ADDRESS).ToString(); 
Debug.WriteLine(olRecipient.Name + " SMTP=" + smtpAddress); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM