使用Exchange 2013 SP1和Exchange Web服务托管API 2.2尝试获取我存储在"公用文件夹"中的联系人文件夹中的联系人列表. 我想将ItemView的大小限制为我在此联系人文件夹中的联系人总数,但是当我尝试返回该属性(contactfolder.TotalCount)时,它总是返回0.如果我尝试使用联系人我邮箱下的文件夹返回0以外的值.我可以通过将ItemView的构造函数的值指定为特定数字或使用int.MaxValue来解决此问题,但我宁愿使用联系人列表中的项目总数.非常感谢任何帮助!这是相关代码:
private FindItemsResults<Microsoft.Exchange.WebServices.Data.Item> ExchangeContacts()
{
// Setup the exchange server connection.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.AutodiscoverUrl("someone@mydomain.com");
// Set the filter to choose the correct contact list
SearchFilter filter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "My Public Contacts");
SearchFilter.SearchFilterCollection filterCollection = new SearchFilter.SearchFilterCollection();
filterCollection.Add(filter);
// Get the FolderId using the search filter.
Folder parent = Folder.Bind(service, WellKnownFolderName.PublicFoldersRoot);
FindFoldersResults results = parent.FindFolders(filter, new FolderView(1));
FolderId fid = results.Single().Id;
// Get the Contact folder based on the folderid.
ContactsFolder …Run Code Online (Sandbox Code Playgroud)