0

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?

Nitendra Jain
  • 489
  • 1
  • 7
  • 24

2 Answers2

1

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

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
0

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); 
Jeff
  • 126
  • 3
  • Not working for me. Throwing error - The property "/O=EXG5/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=Test88067" cannot be parsed or has an invalid format. – Nitendra Jain Aug 19 '13 at 08:06
  • What code are you using? Difficult to diagnose without seeing exactly what you're trying. – Jeff Aug 19 '13 at 08:11