[英]How to Attach to the BeforeAttachmentRead even in Outlook?
I'd like to take some action before users view attachments in Outlook and would like to hook into the BeforeAttachmentRead
event in a VSTO plugin.我想在用户查看 Outlook 中的附件之前采取一些措施,并希望在 VSTO 插件中挂钩BeforeAttachmentRead
事件。 I've seen code that iterates through the inbox and adds the event to each MailItem
:我已经看到了遍历收件箱并将事件添加到每个MailItem
的代码:
foreach (object o in inbox.Items)
{
mailItem = o as Outlook.MailItem;
...
((Outlook.ItemEvents_10_Event)mailItem).BeforeAttachmentRead += new Outlook.ItemEvents_10_BeforeAttachmentReadEventHandler(MailItem_BeforeAttachmentRead);
}
But this seems very inefficient to me (and what about subfolders in the inbox?)但这对我来说似乎效率很低(收件箱中的子文件夹呢?)
Is there a more efficient way to respond to the BeforeAttachmentRead
event?有没有更有效的方法来响应BeforeAttachmentRead
事件?
But this seems very inefficient to me (and what about subfolders in the inbox?)但这对我来说似乎效率很低(收件箱中的子文件夹呢?)
I agree it would be.我同意会的。
I would suggest you subscribe to the selection change event of the Outlook Explorer .我建议您订阅 Outlook Explorer 的选择更改事件。 Now everytime the user selects something you can check if it is a mailitem (it can be other things) and then subscribe to the BeforeAttachmentRead event.现在,每次用户选择某些东西时,您都可以检查它是否是邮件项(它可以是其他东西),然后订阅 BeforeAttachmentRead 事件。 You could actually check for MailItem Attachments count first.您实际上可以先检查MailItem Attachments 计数。 . . If the mail item does not have attachments then you have nothing to do.如果邮件项目没有附件,那么您无事可做。
A few other things to check;其他一些需要检查的事情;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.