问题
I am using VSTO for my Outlook add-in. Currently I am processing email addresses from all Outlook contacts. There is no problem for instances of ContactInfo if EmailAddress1Type is "SMTP".
But how to get email address for Exchange contact (Email1AddressType = "EX")?
Redemption library is not solution for me as it is expensive just to solve this one problem.
Thank you in advance,
Dusan
回答1:
Here is the MSDN reference link and corresponding sample code:
private const string Email1EntryIdPropertyAccessor = "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/80850102";
PropertyAccessor propertyAccessor = contactItem.PropertyAccessor;
object rawPropertyValue = propertyAccessor.GetProperty(Email1EntryIdPropertyAccessor);
string recipientEntryID = propertyAccessor.BinaryToString(rawPropertyValue);
Recipient recipient = contactItem.Application.Session.GetRecipientFromID(recipientEntryID);
if (null == recipient)
throw new InvalidOperationException();
bool wasResolved = recipient.Resolve();
if (!wasResolved)
throw new InvalidOperationException();
ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
string smtpAddress = exchangeUser.PrimarySmtpAddress;
来源:https://stackoverflow.com/questions/3189297/get-smtp-email-from-contactinfo-stored-in-exchange