是否有人举例说明如何通过EWS托管API在Outlook / Exchange中删除用户的SharePoint日历链接?我能够成功找到“日历”链接项,但是执行item.Delete(DeleteMode.HardDelete)却没有实际删除日历链接。任何帮助或指导将不胜感激。
已编辑以包含代码:
//Will target a specific user mailbox with parameter mbMailboxname
static Dictionary<string, Folder> GetSharedCalendarFolders(ExchangeService service, String mbMailboxname)
{
Dictionary<String, Folder> rtList = new System.Collections.Generic.Dictionary<string, Folder>();
DateTime startDate = new DateTime(2018, 8, 1);
DateTime endDate = new DateTime(2018, 8, 31);
CalendarView calView = new CalendarView(startDate, endDate);
Mailbox mb = new Mailbox(mbMailboxname);
FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mb);
FolderView fvFolderView = new FolderView(1000);
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Common Views");
FindFoldersResults ffoldres = service.FindFolders(rfRootFolderid, sfSearchFilter, fvFolderView);
if (ffoldres.Folders.Count == 1)
{
PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
ExtendedPropertyDefinition PidTagWlinkAddressBookEID = new ExtendedPropertyDefinition(0x6854, MapiPropertyType.Binary);
ExtendedPropertyDefinition PidTagWlinkGroupName = new ExtendedPropertyDefinition(0x6851, MapiPropertyType.String);
psPropset.Add(PidTagWlinkAddressBookEID);
ItemView iv = new ItemView(1000);
iv.PropertySet = psPropset;
iv.Traversal = ItemTraversal.Associated;
SearchFilter cntSearch = new SearchFilter.IsEqualTo(PidTagWlinkGroupName, "Other Calendars");
FindItemsResults<Item> fiResults = ffoldres.Folders[0].FindItems(cntSearch, iv);
foreach (Item itItem in fiResults.Items)
{
Microsoft.Exchange.WebServices.Data.Item foundItem = itItem;
if (foundItem.Subject.ToString().Trim().Contains("Company Group Calendar"))
{
Console.WriteLine("Deleting calendar..");
//Executing the delete command here does not delete the calendar
foundItem.Delete(DeleteMode.MoveToDeletedItems);
}
}
}
return rtList;
}