目前我正在使用Outlook Microsoft.Office.Interop.Outlook.SelectNamesDialog
来获取通讯录,但在地址簿(Microsoft.Office.Interop.Outlook.SelectNamesDialog
)中有组电子邮件也。
我正在寻找一种方法来获取该电子邮件组中的所有电子邮件?
答案 0 :(得分:0)
以下是有关如何通过SelectNamesDialog
选择从 Exchange分发列表检索成员的示例。
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;
}
}
}
}
获得地址后,可以很容易地将它们添加到集合中。
答案 1 :(得分:0)
“联系人”文件夹中的分发列表的上一个答案将失败。 您需要做的就是访问Recipient.AddressEntry.Members集合(准备处理空值)。