使用c#

时间:2015-07-13 09:50:53

标签: outlook add-in

我正在开发一个Outlook 2013加载项,我必须在从Outlook地址中选择组后立即将通讯组(可能嵌套或不嵌套)扩展到其组成成员的名称中书。如何实现这一目标? 我完全是新手,从此没有提到任何源代码。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我建议从MSDN中的Getting Started with VBA in Outlook 2010文章开始。

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)部分很有帮助。