首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microsoft.Office.Interop.Outlook.SelectNamesDialog get电子邮件组

Microsoft.Office.Interop.Outlook.SelectNamesDialog get电子邮件组
EN

Stack Overflow用户
提问于 2012-08-15 13:09:12
回答 2查看 1.3K关注 0票数 1

目前我正在使用Outlook Microsoft.Office.Interop.Outlook.SelectNamesDialog获取Contact,但是在地址簿 (Microsoft.Office.Interop.Outlook.SelectNamesDialog)中还有组电子邮件

我在找一种方法来获取邮件组中的所有电子邮件?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-15 14:27:02

下面是如何通过Exchange分发列表通过SelectNamesDialog选择检索成员的示例。

代码语言:javascript
复制
Outlook.SelectNamesDialog names =  Globals.ThisAddIn.Application.Session.GetSelectNamesDialog();
names.SetDefaultDisplayMode(Outlook.OlDefaultSelectNamesDisplayMode.olDefaultMembers);
names.ForceResolution = true;
names.Caption = "Please selection something";
if (names.Display())
{
    Outlook.Recipients recipients = names.Recipients;
    foreach (Outlook.Recipient recipient in recipients)
    {
        Outlook.AddressEntry entry = recipient.AddressEntry;
        if (entry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeDistributionListAddressEntry)
        {
            Outlook.ExchangeDistributionList list = entry.GetExchangeDistributionList();
            Outlook.AddressEntries members = list.GetExchangeDistributionListMembers();
            foreach (Outlook.AddressEntry member in members)
            {
                Outlook.ExchangeUser user = member.GetExchangeUser();
                string address = user.PrimarySmtpAddress;
            }
        }
    }
}

一旦您有了地址,就很容易将它们添加到集合中。

票数 0
EN

Stack Overflow用户

发布于 2012-08-15 17:44:49

对于通讯录文件夹中的通讯组列表,前面的答案将失败。您所需要做的就是访问Recipient.AddressEntry.Members集合(准备处理nulls)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11969866

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档