Outlook Add In - Selecting the Active Inspector on Item Send

依然范特西╮ 提交于 2019-12-25 06:24:07

问题


I am trying to identify the item type on the item send event. I am very close to getting there but the program is not recognising the current item type if a different window has been opened previously.

Here is the code used:

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

My understanding of that code, is that when I select the send button, this code will determine the current type of window that is open and set Item to the corresponding type.

Any help or guidance as to why this is not working would be greatly appreciated!


回答1:


No, all you have to do is the following:

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


来源:https://stackoverflow.com/questions/37787902/outlook-add-in-selecting-the-active-inspector-on-item-send

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