时间:2010-07-06 18:53:37

标签: outlook vsto outlook-addin exchange-server outlook-object-model

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

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

赎回库对我来说不是解决方案,因为解决这个问题很昂贵。

提前谢谢你,

杜桑

1 个答案:

答案 0 :(得分: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;