View Single Post
  #2  
Old March 3rd 10, 03:30 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Get recipient's email address

Yes, that's an Exchange DN type address (an Exchange Distinguished Name).

If the recipient is in the GAL or a contact item you can use this type of
code to get at the SMTP address:

string recipSMTP =
mail.Recipients[1].AddressEntry.GetExchangeUser.PrimarySmtpAddress;

Otherwise you need to access some MAPI properties using PropertyAccessor.
Which property to access depends on whether or not cached Exchange mode is
being used or not. If a direct connection is used you can get the
Recipient.AddressEntry.PropertyAccessor object and use the PR_SMTP_ADDRESS
property tag with it, if cached mode is used you would need to use the
PR_EMS_AB_PROXY_ADDRESSES property tag.

const int PR_SMTP_ADDRESS = 0x39FE001E;
const int PR_EMS_AB_PROXY_ADDRESSES = 0x800F101E;

For use with PropertyAccessor you would use a DASL property tag, which would
look like this:

"http://schemas.microsoft.com/mapi/proptag/" + PR_SMTP_ADDRESS.ToString();
// or the other tag

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message
...
VSTO, OL2007, C#

From our Add-in, most of the time mail.Recipients[1].Address works to
return the recipients email address as say

However, I noticed the following was returned for
mail.Recipients[1].Address this morning from one site instead of an email
address:

/O=COMPANY1/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=SMITH

I assume it has got something to do with the user being on exchange? Is
there anyway to simply get the email address?



Ads