【发布时间】:2017-05-08 19:18:48
【问题描述】:
我有以下代码,它需要花费大量时间从分发列表、交换服务器中检索联系人项目。有什么办法可以调整它的性能
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,例如消息); 返回空值; }
}
【问题讨论】:
标签: c# performance outlook visual-studio-addins