0
我有以下代码,它需要大量的时间从通讯组列表中查找联系人项目,交换服务器。有什么可以做,以调整它的性能性能下降的Outlook插件获取联系人项目的通讯组列表
public Outlook.AddressEntry GetDistributionListMembers(string sParamName,Outlook.Application _OutlookApp) { try { List<string> allAddressEntriesList = new List<string>(); Outlook.AddressLists addrLists = _OutlookApp.ActiveExplorer().Session.AddressLists; var receipientContactList = new List<Outlook.AddressEntry>(); foreach (Outlook.AddressList addrList in addrLists) { if (addrList.AddressEntries.Count <= 0) continue; receipientContactList.AddRange(addrList.AddressEntries.Cast<Outlook.AddressEntry>() .Where(x => x.Address.ToLower().Equals(sParamName.ToLower())));
如果调试
Debug.print(addrList.Name);
ENDIF
if (receipientContactList.Count > 0) break; } return receipientContactList.FirstOrDefault(x => x.GetContact().HasPicture) ?? receipientContactList.FirstOrDefault(); } catch (System.Exception ex) { WriteLog(System.Reflection.MethodBase.GetCurrentMethod().Name,
ex.Message); 返回null; }
}
谢谢德米特里。我需要从本地地址条目中搜索contactitem,还需要在本地outlook实例中搜索GAL和所有可用的地址列表条目。我需要检查联系人项目是否是分发列表,还是单个人,并取决于要显示的数据。你有任何参考/链接看?非常感谢 –
听起来像Namespace.CreateRecipient/Recipient.Resolve是你需要的.. –
谢谢我通过检查oAddressEntry.Type ==“EX”或oAddressEntry.Type ==“SMTP”来解决它。您能否让我知道如何查找发件人/收件人是否为通讯组列表,并根据与其关联的电子邮件帐户的数量计算得出结果。谢谢 –