2016-06-13 5 views
0

アイテム送信イベントでアイテムタイプを識別しようとしています。私はそこに近づいていますが、以前に別のウィンドウが開いていれば、プログラムは現在のアイテムタイプを認識していません。ここで Outlookアドイン - アイテム送信時にアクティブインスペクタを選択する

が使用するコードです:

void Application_ItemSend(object Item, ref bool Cancel) 
    { 
     inspectors = this.Application.Inspectors; 
     currentExplorer = this.Application.ActiveExplorer(); 
     currentExplorer.InlineResponse += ThisAddIn_InlineResponse; 
     Outlook.Inspector inspector = Application.ActiveInspector(); 
     Item = inspector.CurrentItem; 

     try 
     { 
      //Item = inspector.CurrentItem; 
      if (Item == currentAppointment) 
      { 
       TypeCheck = "inspector"; 
      } 

そのコードの私の理解では、私は送信ボタンを選択すると、このコードは対応に開いているウィンドウの現在の種類や設定項目を決定するということですタイプ。

これがなぜ機能していないのかについての助けや指導は、非常に高く評価されます。

答えて

1

いいえ、あなたがしなければならないすべては以下の通りです:

void Application_ItemSend(object Item, ref bool Cancel) 
{ 
    Outlook.MailItem mailItem = Item as Outlook.MailItem; 
    if (mailItem != null) 
    { 
     MessageBox.Show("I am a MailItem"); 
    } 
    else 
    { 
     Outlook.MeetingItem meetingItem = Item as Outlook.MeetingItem; 
     if (meetingItem != null) 
     { 
      MessageBox.Show("I am a MeetingItem"); 
     } 
    } 
} 
関連する問題