【问题标题】:How to Attach to the BeforeAttachmentRead even in Outlook?即使在 Outlook 中,如何附加到 BeforeAttachmentRead?
【发布时间】:2020-11-24 03:05:02
【问题描述】:

我想在用户在 Outlook 中查看附件之前采取一些措施,并想在 VSTO 插件中挂钩BeforeAttachmentRead 事件。我已经看到了遍历收件箱并将事件添加到每个 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);
}

但这对我来说似乎效率很低(收件箱中的子文件夹呢?)

有没有更有效的方式来响应BeforeAttachmentRead 事件?

【问题讨论】:

    标签: c# event-handling vsto outlook-addin outlook-2010


    【解决方案1】:

    但这对我来说似乎效率很低(收件箱中的子文件夹呢?)

    我同意。

    我建议you subscribe to the selection change event of the Outlook Explorer。现在,每次用户选择某些东西时,您都可以检查它是否是 mailitem(它可以是其他东西),然后订阅 BeforeAttachmentRead 事件。您实际上可以检查MailItem Attachments count first.。如果邮件项没有附件,那么您无事可做。

    需要检查的其他一些事项;

    1. 检查 Explorer CurrentFolder.WebViewOn 是否为 false;
    2. 检查选择计数 - 如果它是 1,您只想做某事
    3. 用户可以选择许多不同的东西。在您投射您的选择之前,请检查它实际上是 Outlook.MailItem 类型

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-26
      • 1970-01-01
      相关资源
      最近更新 更多