1

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)

knechtrootrecht
  • 383
  • 2
  • 11
  • I'm confused: are you trying to access the Deleted Items folder in a Shared Mailbox? Or trap when an item is deleted from a Shared Calendar? – Eric Legault Jun 14 '16 at 22:03
  • The deleteion of an Item in a Shared Calendar (not a calendar from a shared Mailbox, these I can access with the stores method as i described).I am using the pattern described in the MSDN to wrap inspectors (No problems there I get the before delete event) But when a user deletes an appointment the only event you get are the folder events. If you wrap the items in the folder events, you get in 7 kinds of RCW hells. – knechtrootrecht Jun 15 '16 at 06:26
  • Are you saying the AppointmentItem.BeforeDelete event is NOT firing for items in the shared calendar even though you have it trapped in an Inspector wrapper? – Eric Legault Jun 15 '16 at 15:43
  • This would theoretically fire if it were wrapped, BUT, there is never a Inspector_New event for D'n'D or Items deleted via the context menu - Wrapping them on selection changes leads to all kind of funny business when there is also an inspector open event. – knechtrootrecht Jun 15 '16 at 15:50
  • What's a "D'nD'? BTW, you can trap the Ribbon control for context menus if you're working with selections. But I hear you - trapping a delete for an item in all possible scenarios is a LOT of work. This is where Redemption can be handy, as you can trap a single delete event for an entire Store. – Eric Legault Jun 16 '16 at 02:24
  • D'n'D is Drag and Drop. I'll certainly try the Redemption way, but I am not too optimistic that I can get a hold of the Store for I cant get it via Folder.Store although Folder.StoreId holds the correct EntryID of the Folder – knechtrootrecht Jun 16 '16 at 06:36
  • Stores wont cut it either, I can get the event that somthing happened but i cant cancel it , which is neccessary for my application – knechtrootrecht Jun 16 '16 at 12:58
  • Yes, using Redemption for trapping global deletes won't help for a shared folder. Are you say DnD doesn't fire NewInspector if you drag an email onto the Calendar module to create a new Appointment? – Eric Legault Jun 16 '16 at 21:37
  • I ment DnD does not fire a new inspector when moving Appointments around, when creating Appointments everything works just fine. As a workaround I am accessing and releasing the inspector via Selection[x].GetInspector (which triggers the NewInspector) – knechtrootrecht Jun 17 '16 at 06:21
  • If you need to trap moving an appointment from one Calendar to another in a folder view then you'll need to also trap Items.ItemRemove for the source folder. – Eric Legault Jun 17 '16 at 15:49
  • No it's a movement within a folder – knechtrootrecht Jun 17 '16 at 15:51
  • How do you mean? An item can't be moved to the same folder it is already in – Eric Legault Jun 17 '16 at 16:30
  • I can drag an Appointment from Time A to another Time B in the same calendar – knechtrootrecht Jun 20 '16 at 10:42

2 Answers2

0

RDOStore.GetDefaultFolder(olFolderDeletedItems) and RDOSession.GetSharedDefaultFolder(olFolderDeletedItems) both work in Redemption.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • RDOSession.GetSharedDefaultFolder(olFolderDeletedItems) wont work, as stated in the RDO Documentation : "The type of the folder. Accepts the same values as Namespace.GetDefaultFolder method in Outlook Object Model" and in the MSDN [Documentation](https://msdn.microsoft.com/en-us/library/office/ff869575.aspx) They write that one mustn't use olFolderDeletedItems. Which is consistent with my error code of "Illegal argument" – knechtrootrecht Jun 20 '16 at 10:39
  • On a sidenote: get GetSharedDefaultFolder(NameOrAddressOrObject, FolderType) needs An RDOAddressentry or RDORecipient or a name or an email Address – knechtrootrecht Jun 20 '16 at 13:59
  • GetSharedDefaultFolder in **Redemption** has no such limitation. olFolderDeletedItems is just another default folder. – Dmitry Streblechenko Jun 20 '16 at 19:39
  • I tried your suggested method today again in an empty project. All I get is a COM Exception with the Info : "Could not find the Store DN". Which is expected since I only get an EntryID for the Store in the Folder object (either OOM or RDO), the Folder.Store property itself is null. – knechtrootrecht Jun 21 '16 at 06:14
  • That sounds like an error returned when you try to open the shared mailbox, not when you open the Deleted Items folder. What is your code that opens the store? – Dmitry Streblechenko Jun 21 '16 at 14:58
  • You just gave me an Idea why this cannot be working ! In a situation where somebody shares only their calendar, I can access only this special Folder. Because it belongs to a Store I can "see" the StoreID, but not access Folder.Store. Which is also the reason I can't get access to the store, or to a Shared Default folder e.g. olDeletedItems, this works only if the user not only shared their calendar, but also their Mailbox. – knechtrootrecht Jun 27 '16 at 07:02
0

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)

knechtrootrecht
  • 383
  • 2
  • 11