Nitendra Jain
Nitendra Jain

Reputation: 499

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?

Upvotes: 0

Views: 869

Answers (2)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66286

Use Recipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress (error/null checking omitted).

Upvotes: 1

Jeff
Jeff

Reputation: 126

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); 

Upvotes: 0

Related Questions