1

AppointmentItemすべてのsendイベントにイベントハンドラーを追加します。このイベントハンドラーは、ログ記録を行うだけです。Outlook 2003を使用して会議を作成してから、会議を2回更新します。最後にログを確認します。

this.Application.Inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(_inspectors_NewInspector);

private void _inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector inspector)
{
    if(inspector.CurrentItem is Outlook.AppointmentItem)
    {
        _appointmentEvent = inspector.CurrentItem as Outlook.ItemEvents_10_Event;
        _appointmentEvent.Send += new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(_appointmentEvent_Send);
    }
}

private void _appointmentEvent_Send(ref bool Cancel)
{
    Log.WriteLog("InspectorWrapper: _appointmentEvent_Send Enter");
    Log.WriteLog("InspectorWrapper: _appointmentEvent_Send Exit");
}

ログを確認します。sendイベントハンドラーが何度も呼び出されることがわかりました。

2012-05-16 10:07:21:066:InspectorWrapper:_appointmentEvent_Send Enter
2012-05-16 10:07:21:067:InspectorWrapper:_appointmentEvent_Send Exit
...
2012-05-16 10:07:27:281: InspectorWrapper:_appointmentEvent_Send Enter
2012-05-16 10:07:27:283:InspectorWrapper:_appointmentEvent_Send Exit
2012-05-16 10:07:27:283:InspectorWrapper:_appointmentEvent_Send Enter
2012-05-16 10:07:27:284 :InspectorWrapper:_appointmentEvent_Send Exit
...
2012-05-16 10:07:32:607:InspectorWrapper:_appointmentEvent_Send Enter
2012-05-16 10:07:32:608:InspectorWrapper:_appointmentEvent_Send Exit
2012-05-16 10:07 :32:609:InspectorWrapper:_appointmentEvent_Send Enter
2012-05-16 10:07:32:609:InspectorWrapper:_appointmentEvent_Send Exit
2012-05-16 10:07:32:610:InspectorWrapper:_appointmentEvent_Send Enter
2012-05-16 10:07:32:610:InspectorWrapper:_appointmentEvent_Send出口

なんで?

4

1 に答える 1

0

イベントにログを追加して、NewInspectorイベントにラッチする回数を確認する必要がありますAppointmentItem.Send。私の仮定はそれNewInspectorがあなたの問題だということです。InspectorWrapper複数のイベントのラッチを回避するために、カスタムをコンテナーとして使用して、アクティブなインスペクターのリストを管理することをお勧めします。

参考までにFindOutlookInspectorこのMSDNリファレンスを参照してください。

internal static List<OutlookInspector> m_Windows;       
internal static OutlookInspector FindOutlookInspector(object window)
{
    foreach (OutlookInspector inspector in m_Windows)
        if (inspector.Window == window)
            return inspector;
    return null;
} 
于 2012-05-16T14:23:35.303 に答える