在远程计算机上删除项目时,Outlook中未触发BeforeItemMove事件 [英] BeforeItemMove event not fired in Outlook when item is deleted on remote machine

查看:97
本文介绍了在远程计算机上删除项目时,Outlook中未触发BeforeItemMove事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Outlook加载项,其中有一些事件,当从草稿中删除某个项目时会触发这些事件.因此,当我从计算机上的草稿中删除文件时,会触发BeforeItemMove事件.

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.

但是有趣的情况到了.此外,我还有一个VM,在其中安装了Outlook,并登录到同一帐户.所以我的草稿也在那里同步了.当我在VM上删除草稿时,一段时间后,草稿也会在我的系统上被删除.但是这一次它不会在我的本地计算机上触发BeforeItemMove事件.我想念什么?它甚至依赖于Exchange吗?还是我应该订阅的文件夹更新新事件?下面是我的代码.

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);

事件方法是

private void BeforeItemMoveFromDrafts(object Item, MAPIFolder MoveTo, ref bool Cancel)
{

...

}

PS.我还引用了文件夹对象,所以这不是问题.

PS. I also have a reference to the folder object, so that is not the issue.

推荐答案

据我了解,

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.确保在全局范围内声明了源对象,以防止其被垃圾收集器刷卡.

P.S. Make sure that the source object is declared at the global scope to prevent it from swiping by the garbage collector.

这篇关于在远程计算机上删除项目时,Outlook中未触发BeforeItemMove事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆