2

我正在为我的Outlook加载项使用VSTO。目前我正在处理所有Outlook联系人的电子邮件地址。如果EmailAddress1Type是“SMTP”,则ContactInfo的实例没有问题。从存储在Exchange中的ContactInfo获取Smtp电子邮件

但如何获取Exchange联系人的电子邮件地址(Email1AddressType =“EX”)?

救赎图书馆对我来说并不是解决方案,因为解决这个问题很昂贵。

谢谢你在前进,

杜尚

回答

5

这里是MSDN reference link和相应的示例代码:

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;