Outlook 加载项 - 在项目发送时选择活动检查器

Outlook Add In - Selecting the Active Inspector on Item Send

我正在尝试识别项目发送事件中的项目类型。我快要到达那里了,但是如果之前打开了不同的 window,程序将无法识别当前项目类型。

这里是使用的代码:

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

我对那段代码的理解是,当我select发送按钮时,这段代码会判断当前打开的window类型,并将Item设置为相应的类型。

任何关于为什么这不起作用的帮助或指导将不胜感激!

不,您只需执行以下操作:

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