Get Smtp email from ContactInfo stored in Exchange

丶灬走出姿态 提交于 2019-12-01 11:24:54
SamFlushing

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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!