VSTO Outlook 加载项 如何从 Outlook 通讯组列表中检索 Exchange 通讯组列表成员

发布于 2024-11-15 04:35:16 字数 413 浏览 10 评论 0原文

我有 VSTO 插件,可以从邮件项目中获取收件人并将其保存在我们的用户列表中。 在交换通讯组列表或交换联系人作为收件人的情况下,通过从这两者中提取 smtp 邮件地址可以正常工作。为此,Outlook 对象模型起作用了。

但是,当将 Exchange 通讯组列表添加为 Outlook 通讯组列表中的成员并将邮件发送到此本地通讯组列表时,就会出现问题。有没有办法从这个嵌套通讯组列表中提取每个联系人的 smtp 地址。

到目前为止,我有用户 DistListItem.GetMember(i) 方法来获取此通讯组列表的成员。它提供了一个 Recipient 对象,当我尝试从此对象访问属性 member.AddressEntry.AddressEntryUserType 时,它​​会抛出异常“找不到该项目”。 有谁知道如何从该收件人对象获取通讯组列表成员类型或entryId?

I have VSTO Add-in that gets the recipient from the mailitem and save it in our user list.
In case of exchange distribution list or exchange contact as a recipient it works fine by extracting smtp mail address from both of these. For this purpose outlook object model works.

but the problem arises when exchange distribution list is added as a member in the outlook distribution list and mail is sent to this local distribution list. Is there any way to extract smtp addresses of each contact from this nested distribution list.

So far I have user DistListItem.GetMember(i) Method to get a member of this distribution list. It provides a Recipient object and when i try to access a property member.AddressEntry.AddressEntryUserType from this object it throw an exception "The item could not be found".
Does anyone knows how can i get a distribution list member type or entryId from this recipient object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞陪衬 2024-11-22 04:35:16
    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);
                }
        }
    }
}
    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);
                }
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文