目前我正在使用Outlook Microsoft.Office.Interop.Outlook.SelectNamesDialog获取Contact,但是在地址簿 (Microsoft.Office.Interop.Outlook.SelectNamesDialog)中还有组电子邮件。
我在找一种方法来获取邮件组中的所有电子邮件?
发布于 2012-08-15 14:27:02
下面是如何通过Exchange分发列表通过SelectNamesDialog选择检索成员的示例。
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;
}
}
}
}一旦您有了地址,就很容易将它们添加到集合中。
发布于 2012-08-15 17:44:49
对于通讯录文件夹中的通讯组列表,前面的答案将失败。您所需要做的就是访问Recipient.AddressEntry.Members集合(准备处理nulls)。
https://stackoverflow.com/questions/11969866
复制相似问题