【问题标题】:Outlook Add In, Audit when a mail read for the first timeOutlook Add In,第一次阅读邮件时审核
【发布时间】:2017-02-20 03:54:24
【问题描述】:

当有人阅读他们的邮件时,我整理了以下代码来编写一个事件。但我只需要在第一次阅读时才写。关于如何实现这一点的任何想法。

private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            inspectors = this.Application.Inspectors;
            inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
            application = new Outlook.Application();
            oINS = application.GetNamespace("MAPI");

        }

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
        {
            currentItem = Inspector.CurrentItem as Outlook.MailItem;
            currentItem.Read += new Outlook.ItemEvents_10_ReadEventHandler(item_read);

        }

void item_read()
        {
            WriteAudit("Item being read newly");
        }

【问题讨论】:

    标签: c# outlook outlook-addin


    【解决方案1】:

    我注意到下面这行代码:

     application = new Outlook.Application();
    

    无需在Startup 事件处理程序中创建新的应用程序实例。相反,您可以使用加载项类的 Application 属性。

    在这种情况下,您需要保留未读项目 ID 列表,以检查邮件项目是否较早打开。

    但是有一个更简单的解决方案。处理 MailItem 类的 PropertyChange 事件,该事件在父对象实例的显式内置属性(例如,Subject)发生更改时触发。您对UnRead 属性更改感兴趣。如果 Outlook 项目尚未打开(读取),则该属性返回一个布尔值 True。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-09
      • 1970-01-01
      • 2015-05-12
      • 2022-01-18
      • 2017-02-19
      • 2018-04-09
      • 2017-09-05
      • 2018-07-08
      相关资源
      最近更新 更多