下面是我的代码,用于在Outlook的搜索文件夹中添加一个名为“ 所有收件箱”的文件夹。选中Outlook设置“ 使用缓存的Exchange模式”复选框(即已启用)时,此代码可以正常工作。
public FolderId CreateSearchFolder(List<FolderId> listofFolderId)
{
try
{
// Create the folder.
var searchFolder = new SearchFolder(Service) { DisplayName = "AllInboxItems" };
var searchfilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, true);
searchFolder.SearchParameters.RootFolderIds.Add(WellKnownFolderName.Inbox);
foreach (var entry in listofFolderId)
{
searchFolder.SearchParameters.RootFolderIds.Add(entry);
}
searchFolder.SearchParameters.SearchFilter = searchfilter;
// Call Save to make the EWS call to create the folder.
searchFolder.Save(WellKnownFolderName.SearchFolders);
return searchFolder.Id;
}
catch (Exception ex)
{
return null;
}
}
我想知道为什么使用Exchange缓存模式设置已启用 时,此代码为何失败。有什么我想念的吗?