BeforeItemMove event not fired in Outlook when item is deleted on remote machine

≯℡__Kan透↙ 提交于 2020-01-03 02:54:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/37916179/beforeitemmove-event-not-fired-in-outlook-when-item-is-deleted-on-remote-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!