VSTO Addin Outlook约会删除和写入事件仅在首先打开时触发

时间:2017-09-02 15:42:45

标签: c# vsto outlook-addin inspector

我正在使用Outlook Addin,我尝试在删除时执行特定操作。它适用于我已经打开一次的所有约会。在未首先打开日历的情况下创建或删除约会时,不会触发任何事件(BeforeDelete,Write)。

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    inspectors = this.Application.Inspectors;
    inspectors.NewInspector +=
    new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
}
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
    appointmentItem = Inspector.CurrentItem as Outlook.AppointmentItem;
    if (appointmentItem != null)
    {
        (appointmentItem as Microsoft.Office.Interop.Outlook.ItemEvents_10_Event).Send += _appointment_Send;
        (appointmentItem as Microsoft.Office.Interop.Outlook.ItemEvents_10_Event).BeforeDelete += _appointment_Delete;
        (appointmentItem as Microsoft.Office.Interop.Outlook.ItemEvents_10_Event).Write += _appointment_Write;    
        (appointmentItem as Microsoft.Office.Interop.Outlook.ItemEvents_10_Event).Open += _appointment_Open;
        (appointmentItem as Microsoft.Office.Interop.Outlook.ItemEvents_10_Event).Close += _appointment_Close;
    }
}

我认为解释的关键在于,只有在约会开放时才会附加检查员,并且要遵循的路径更像描述here,但我不确定。上述代码的工作方式类似于在删除或创建约会之前未打开约会的特殊情况下的魅力。

非常感谢任何指导。

1 个答案:

答案 0 :(得分:1)

是的,BeforeWrite不会触发。如果我在Outlook中选择约会并查看OOM使用OutlookSpy触发的事件(选择约会,单击项目按钮,转到事件选项卡并查看页面底部的日志,修改约会inline),我只能看到以下事件。

删除约会时,

"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempor enim nec velit egestas scelerisque. Etiam id leo sit amet magna ornare scelerisque. Sed pretium mollis nibh dignissim consectetur.</p>" 按预期触发。

BeforeDelete