如何检测用户何时在 Outlook VSTO 中选择新邮件或打开邮件

How detect when user choose NEW or OPEN mail in Outlook VSTO

我正在 Outlook 2016 中编写 VSTO,我想在功能区中 enable/disable 按钮,基于用户的“开始新消息”或 OPEN/READ 一条消息的操作。

我的问题是如何检测用户何时按下新邮件或只打开 sent/received 一封邮件。

有人能帮帮我吗? 谢谢!

This tutorial 实际上处理的是这种情况:

private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        inspectors = this.Application.Inspectors;
        inspectors.NewInspector +=
        new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
    }

具体来说,您附加到 this.Appliaction.Inspectors。教程趁机修改新的MailItem:

SubjectBody属性
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
        {
            Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
            if (mailItem != null)
            {
                if (mailItem.EntryID == null)
                {
                    mailItem.Subject = "This text was added by using code";
                    mailItem.Body = "This text was added by using code";
                }

            }
        }