如何使用EWS 2.0恢复已删除的约会? 我想我可以在WellKnownFolderName.RecoverableItemsDeletions文件夹中搜索它。但我所拥有的只是ItemId。遗憾的是我无法在SearchFilter中使用它......
最好的方法是什么?
我的尝试:
ItemView view = new ItemView(10);
SearchFilter searchFilter = new SearchFilter.IsEqualTo(ItemSchema.Id, itemChange.ItemId);
var findResults = exchangeService.FindItems(WellKnownFolderName.RecoverableItemsDeletions, searchFilter, view);
List<ItemId> ids = null;
foreach (var findResult in findResults)
{
Debug.WriteLine(findResult.Id.ToString());
ids.Add(findResult.Id);
}
exchangeService.MoveItems(ids, WellKnownFolderName.Calendar);
发生错误:
{“'ItemId'类型的值不能用作搜索过滤器中的比较值。”}
答案 0 :(得分:1)
在搜索约会时将WellKnownFolderName设置为DeletedItems。并且您应该将搜索过滤器设置为仅返回约会,因为DeletedItems文件夹可以容纳的不仅仅是您要查找的约会。这是一个适合你的例子。
ItemView view = new ItemView(10);
// Only look for appointments
SearchFilter searchFilter = new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "IPM.Appointment");
// Look for items in the DeletedItems folder
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.DeletedItems, searchFilter, view);
// Move each of the deleted items back to the calendar
List<ItemId> ItemsToMove = new List<ItemId>();
foreach (Item item in results)
{
ItemsToMove.Add(item.Id);
}
service.MoveItems(ItemsToMove, WellKnownFolderName.Calendar);