We have recently had a case where the BeforeItemMove event wasn’t being triggered when switching between two calendar folders in Outlook 2007 or 2010.
To subscribe for the event we were using the Outlook.Explorer.CurrentFolder property to retrieve the currently selected folder and that same object was being used for subscribing for the events.
We have done a bit of debugging around this and we have noticed that even though the CurrentFolder property was returning the correct data of the currently selected folder, the returned COM object was always the same. Because of this behaviour, we were subscribing for events for the same folder over and over again.
As a workaround, instead of using the Outlook.Explorer.CurrentFolder to retrieve an Outlook.Folder item, you need to use the Namespace.GetFolderFromID method as follows:
1: Outlook.Folder currentFolder;
2: Outlook.Namespace _Namespace;
4: /// <summary>
5: /// This event occures when another folder has been selected in this explorer.
6: /// </summary>
7: void _Explorer_FolderSwitch()
10: if (currentFolder != null)
12: currentFolder.BeforeItemMove -= new Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(_Folder_BeforeItemMove);
15: currentFolder = (Outlook.Folder)ThisAddIn._NameSpace.GetFolderFromID(_Explorer.CurrentFolder.EntryID);
17: if (currentFolder == null)
20: currentFolder.BeforeItemMove += new Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(_Folder_BeforeItemMove);