2015-07-13 82 views
0

我正在開發一個Outlook 2013加載項,其中必須儘快將展現通訊組(可以嵌套也可以不嵌套)分配到其組成成員的名稱中組從Outlook地址簿中選擇。如何實現? 我完全是新手,從此以後沒有提到源代碼。任何幫助將不勝感激。在Outlook中使用c檢索嵌套通訊組的成員

回答

0

我建議從Getting Started with VBA in Outlook 2010 MSDN文章開始。

private void GetDistributionListMembers() 
{ 
    Outlook.SelectNamesDialog snd = 
     Application.Session.GetSelectNamesDialog(); 
    Outlook.AddressLists addrLists = 
     Application.Session.AddressLists; 
    foreach (Outlook.AddressList addrList in addrLists) 
    { 
     if (addrList.Name == "All Groups") 
     { 
      snd.InitialAddressList = addrList; 
      break; 
     } 
    } 
    snd.NumberOfRecipientSelectors = 
     Outlook.OlRecipientSelectors.olShowTo; 
    snd.ToLabel = "D/L"; 
    snd.ShowOnlyInitialAddressList = true; 
    snd.AllowMultipleSelection = false; 
    snd.Display(); 
    if (snd.Recipients.Count > 0) 
    { 
     Outlook.AddressEntry addrEntry = 
     snd.Recipients[1].AddressEntry; 
     if (addrEntry.AddressEntryUserType == 
     Outlook.OlAddressEntryUserType. 
      olExchangeDistributionListAddressEntry) 
     { 
      Outlook.ExchangeDistributionList exchDL = 
      addrEntry.GetExchangeDistributionList(); 
      Outlook.AddressEntries addrEntries = 
      exchDL.GetExchangeDistributionListMembers(); 
      if (addrEntries != null) 
       foreach (Outlook.AddressEntry exchDLMember in addrEntries) 
      { 
       Debug.WriteLine(exchDLMember.Name); 
      } 
     } 
    } 
} 

查看How to: Get Members of an Exchange Distribution List瞭解更多信息。

您可能會發現MSDN中的How Do I... (Outlook 2013 PIA Reference)部分有幫助。