【问题标题】:Get Smtp email from ContactInfo stored in Exchange从存储在 Exchange 中的 ContactInfo 获取 Smtp 电子邮件
【发布时间】:2011-03-12 11:37:03
【问题描述】:

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

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

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

提前谢谢你,

杜山

【问题讨论】:

    标签: outlook vsto exchange-server outlook-addin


    【解决方案1】:

    这里是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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-26
      相关资源
      最近更新 更多