2015-06-21 27 views
1

我想使用SelectNamesDialog在我的Outlook加載項中獲取聯繫人詳細信息。如果用戶在對話框中選擇單個聯繫人項目,我可以使用SelectNamesDialog獲取每個聯繫人項目的詳細信息。收件人屬性。我的問題是,如果用戶選擇一個聯繫人組而不是單個聯繫人,那麼我可以獲得其成員。我能夠區分,如果是單個用戶或使用該聯繫人組:使用SelectNamesDialog獲取聯繫人組的成員

Outlook.SelectNamesDialog NamesDialog = Globals.ThisAddIn.Application.Session.GetSelectNamesDialog(); 
NamesDialog.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo; 
NamesDialog.ForceResolution = true; 

NamesDialog.Display(); 
foreach (Outlook.Recipient recipient in NamesDialog.Recipients) 
{ 
    if (recipient.DisplayType == Outlook.OlDisplayType.olUser) 
    { 

    } 
    else if (recipient.DisplayType == Outlook.OlDisplayType.olPrivateDistList) 
    { 
    } 
} 

但我無法得到聯繫人的詳細信息,如果它是一個聯絡小組(DistList)。

你可以給我一些提示,我可以如何獲得成員如果NamesDialog。收件人是聯繫人組,而不是單個用戶。

非常感謝。

回答

0
  Outlook.ExchangeDistributionList exchDL = addrEntry.GetExchangeDistributionList(); 
      Outlook.AddressEntries addrEntries = exchDL.GetExchangeDistributionListMembers(); 
      if (addrEntries != null) 
       foreach (Outlook.AddressEntry exchDLMember in addrEntries) 
       { 
        Debug.WriteLine(exchDLMember.Name); 
       } 
+0

嗨,謝謝你的回覆。我試試這個: Outlook.AddressEntry addEntry = recipient.AddressEntry; Outlook.ExchangeDistributionList exchDL = addEntry.GetExchangeDistributionList(); 但exchDL保持空 –