Outlook 2010 AddIn:是否有在将项目添加到文件夹*之前*触发的事件?
我正在编写一个 Outlook 插件,它应该提供一个新的特殊文件夹,用户可以将邮件项目拖入其中,以便由插件处理它们。
现在,每当用户尝试执行此操作时,我都希望收到通知;但在它发生之前。然而,似乎没有办法做到这一点。
使用文件夹的 BeforeItemMove
事件,当用户尝试将项目移出文件夹时,Outlook 会通知我 - 但没有什么比 BeforeItemAdd
更好的了事件。
接近的一件事是文件夹项目集合的 ItemAdd
事件,但该事件在添加项目后触发;那时,手术已经完成。我看不出有什么方法可以判断该项目最初来自哪里,或者(与 BeforeItemMove
事件不同)在 AddIn 确定该项目由于某种原因无效时取消该操作。
理论上,我应该能够向所有其他文件夹添加一个 BeforeItemMove
处理程序,并在移动目标是由我的 AddIn 管理的文件夹时对它们做出反应,但这看起来像有点过分了……有没有更简单的方法?
I'm writing an Outlook AddIn which is supposed to offer a new special folder which the user can drag mail items into, in order to have them processed by the AddIn.
Now I'd like to be informed whenever the user tries to do that; but before it happens. However, there does not seem to be a way to do that.
Using the folder's BeforeItemMove
event, Outlook informs me when the user tries to move an item out of the folder - but there is nothing like a BeforeItemAdd
event.
The one thing that comes close is the ItemAdd
event of the folder's items collection, but that one fires after an item has been added; at that time, the operation has already been completed. I see no way to tell where the item originally came from or (unlike the BeforeItemMove
event) to cancel the operation in case the AddIn determines that it is not valid for some reason.
Theoretically, I should be able to add a BeforeItemMove
handler to all the other folders and react to them whenever the move target is the folder managed by my AddIn, but that seems like a bit of overkill... isn't there an easier way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不能这样做,所有 MAPI 事件都是异步的,并且在发生某些事情后触发。
Outlook 确实会同步触发一些 UI 事件(如 BeforeItemMove),但没有像 BeforeItemAdd 那样的事件。
Can't do that, all MAPI events are asynchronous and fire after something happens.
Outlook does fire some UI evenst synchronously (like BeforeItemMove), but there is nothing like BeforeItemAdd.