2011-06-02 44 views
9

在我的VSTO Outlook 2007插件中,我可以獲取作爲交換用戶的收件人的電子郵件地址。但是,當我遇到以下情況時,它不會返回我的smtp電子郵件:獲取作爲交換用戶的收件人的電子郵件地址

  1. 添加新的Outlook聯繫人項目(在Outlook聯繫人中)。
  2. 此聯繫人項目的電子郵件地址應該是交換用戶(貴組織的任何人員,但是交換用戶)的電子郵件地址。
  3. 現在,當我選擇此Outlook聯繫人作爲電子郵件收件人和項目發送事件時,我無法獲取smtp地址。

下面是我的代碼:

Recipient r = mailItem.Recipients[i]; 
r.Resolve(); 
//Note, i have different conditions that check the AddressEntryUserType of recipient's 
//address entry object. All other cases work fine. In this case this is 
//olOutlookContactAddressEntry. 
//I have tried the following: 

ContactItem cont = r.AddressEntry.GetContact(); 
string email = cont.Email1Address; 
string emailtmp = r.AddressEntry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101E") as string; 

任何人都可以請幫我,我應該在這種情況下,用什麼屬性來獲取SMTP電子郵件?

+0

我也有這個問題,並不能從收件人的電子郵件或約會項目的SMTP地址。我只能看到這樣的地址 - 「Address =」/ o = INCORPORATION/ou = Exchange Administrative Group(XXXXXXXXXXXX)/ cn = Recipients/cn = username「' – kavun 2011-07-27 13:27:19

回答

0

如果我沒有記錯,有幾個情況下電子郵件地址不會解決,除非您保存首先發送的項目。你可以試試。此外,你是否沒有收到任何「安全違規」信息,要求獲得訪問用戶通訊錄的權限,或者是否已禁用/解決了所有這些問題?我有很多probs,最終需要使用Redemption來展望。

+0

其實我沒有訪問Outlook的通訊錄。這是我嘗試訪問郵件地址的郵件項目的收件人對象。此外,聯繫人項目在我訪問收件人的電子郵件地址之前已經保存。 – 2011-06-07 14:05:50

4

我找到了一種使用ExchangeUser項目並通過該對象解析smtp地址的方法。這個職位幫助 - Get Smtp email from ContactInfo stored in Exchange

foreach (Outlook.Recipient recipient in currentAppointment.Recipients) 
    { 
     Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser(); 
     string smtpAddress; 
     if (exchangeUser != null) 
     { 
      smtpAddress = exchangeUser.PrimarySmtpAddress; 
     } 
     else 
     { 
      smtpAddress = recipient.Address; 
     } 
    } 
+1

GetExchangeUser()需要持久交換連接 – 2012-01-04 18:28:58

+1

我有一個Exchange聯繫人,其中GetExchangeUser返回null。仍然收件人。地址具有此wirde/o = FIRM/ou =某些組/ cn = f.name。 – lokimidgard 2017-05-10 12:22:00

相關問題