VSTO Addin Outlook Appointment delete and write event fired only if opened first

﹥>﹥吖頭↗ 提交于 2019-12-11 17:25:00

问题


I am working on an Outlook Addin where I try to perform a specific action if deleted. It works fine with all the appointments that I have already opened once. When the appointment is created or deleted from the calendar without being open first no event (BeforeDelete, Write) is fired.

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;
    }
}

I would assume that the explanation lies in the fact inspectors are only attached when the appointment is open and that the path to follow is something more like described here but I am not sure. The above code works like a charm excepted for the specific case where the appointment is not opened before being deleted or created.

Any guidance will be much appreciated.


回答1:


Yes, BeforeWrite does not fire. If I select an appointment in Outlook and look at the events fired by OOM using OutlookSpy (select the appointment, click Item button, go to the Events tab and look at the log at the bottom of the page, modify the appointment inline), I can only see the following events fire.

BeforeDelete fires as expected when the appointment is deleted.

PropertyChange (ConversationIndex)
PropertyChange (Subject)
PropertyChange (Start)
PropertyChange (StartInStartTimeZone)
PropertyChange (StartUTC)
PropertyChange (End)
PropertyChange (EndInEndTimeZone)
PropertyChange (EndUTC)
PropertyChange (Duration)
PropertyChange (AllDayEvent)
PropertyChange (StartInStartTimeZone)
PropertyChange (StartUTC)
PropertyChange (End)
PropertyChange (EndInEndTimeZone)
PropertyChange (EndUTC)
PropertyChange (Start)
PropertyChange (EndInEndTimeZone)
PropertyChange (EndUTC)
PropertyChange (Duration)
PropertyChange (End)
PropertyChange (MeetingStatus)
Write (false)
BeforeCheckNames (false)
AfterWrite ()
<Unknown(DispID=0x0000FC95)> (false)


来源:https://stackoverflow.com/questions/46015455/vsto-addin-outlook-appointment-delete-and-write-event-fired-only-if-opened-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!