Determine if the current Outlook window is forward email?

I have an Outlook plugin. I have an inspector handler that calls a method when a new window opens. I want this method to perform "something" only if the current window is a direct message window (the window that opens when you click the "forward" button in an email). My current code works, but it works with all new windows, including "Reply / New Email", etc.

Any help I can check to see if the new window is a forward mailbox?

My code is:

...
Outlook.Inspectors olInspectors;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {  ......
        olInspectors = this.Application.Inspectors;
        olInspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(Forward_Message_Inspector);
    }

void Forward_Message_Inspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    {
      //how do I check here if current window is a forward message window?
          //and then do something
    }

Thanks in advance for any help.

+4
source share
2 answers

, Subject .

void Forward_Message_Inspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
    Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
    if (mailItem != null)
    {
        if (mailItem.Subject.StartsWith("FW: "))
        {
          //do something here
        }
    }
}

, Mail Body

+5

/ Inspector MailItem.Forward, / MailItem.

- PR_ICON_INDEX ( 262 ) PR_LAST_VERB_EXECUTED (104 ) MailItem PropertyAccessor.

+3

Source: https://habr.com/ru/post/1569349/


All Articles