Search code examples
c#vstooutlook-addinoutlook-redemptionoutlook-2016

Outlook Interop Accessing Deleted Item Folder from Shared Calendar


Consider the following scenario: Sombody shared a calendar with me. I have full access to this calendar. When i delete an Item in the calendar the Folder.BeforeItemMove Event is fired. So far so good. I want to Track deletion by check wether the MoveTo Entry id is null or the Entry id of the Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems) which works. Now back to the case where the item is in a shared folder:

  • As per documentation the Property olFolderDeletedItems is a no go as parameter for GetSharedDefaultFolders() (Just to be sure i accessed the other folders which were allowed which worked)
  • I tried to Iterate over the Stores collection. No calendar there
  • I tried to Access the Store Property on the MoveTo folder -> null
  • I tried to get the Store from the Session (to inspect the PR_IPM_WASTEBASKET_ENTRYID) -> Fails
  • I CAN get the folder name Problem with this is , it might be renamed and/or localized and i do not want an array with all the deleted folder names floating around if i can't help it
  • I tested all of this using either plain OOM or redemptions Folder interface

Any Ideas?

(Tested in Outlook 2016)


Solution

  • If you have access to the Calendar as a Shared Calendar (e.g. Sent as EMail invitation to you via the OWA) deleted Items go to YOUR deleted items Folder. This you can get via Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems)

    If the Calendar is in a second mailbox in your profile the deleted item go to the deleted items folder of THAT account which you can acces via

    Outlook.Store _Store = MoveTo.Store;

    Outlook.Folder _Folder = MoveTo.GetDefaultFolder (OlDefaultFolders.olFolderDeletedItems) as Outlook.Folder;

    You can differntiate these two scenarios by Checking if the Folder.Store is null (which it is in the case of an Shared non mailbox calendar)