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; 
相關問題