Reputation: 1254
I am developing an outlook add-in, where I have events which will be fired when an item is deleted from drafts. So when I delete the files from my drafts on my machine, the BeforeItemMove
event is fired.
But here comes the interesting case. Additionally I also have a VM, where I have outlook installed and logged in to the same account. So my drafts are synced there as well. When I delete a draft on the VM, after some time the draft gets deleted on my system as well. But this time it doesn't fire the BeforeItemMove
event on my local machine. What am I missing? Is it even dependent on Exchange? Or is a new event for folder update that I should subscribe to? Below is my code.
Microsoft.Office.Interop.Outlook.Folder draftsFolder = null;
draftsFolder = nameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDrafts) as Microsoft.Office.Interop.Outlook.Folder;
draftsFolder.BeforeItemMove += new Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(BeforeItemMoveFromDrafts);
The event method is
private void BeforeItemMoveFromDrafts(object Item, MAPIFolder MoveTo, ref bool Cancel)
{
...
}
PS. I also have a reference to the folder object, so that is not the issue.
Upvotes: 1
Views: 763
Reputation: 49395
In my understanding the BeforeItemMove event shouldn't be fired on another machines. It is fired when an item is about to be moved or deleted from a folder, either as a result of user action or through program code. The code should be run against the local Outlook instance.
P.S. Make sure that the source object is declared at the global scope to prevent it from swiping by the garbage collector.
Upvotes: 1