skip to Main Content

I am trying to create plug-in that will catch any send item and show warning before sent out.
Currently I am using the below code

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Outlook.Application application = Globals.ThisAddIn.Application;
            application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
            
        }

However, I noticed it catches almost all the send event but when send button is pressed from main screen of Outlook, I mean when the mail is not popped out to separate window, it does not catch the event and my plugin function is not executed. My environment is Visual Studio 2019 and Outlook 2019. Any advise is appreciated.

Thank you,

Catch all the send event from Outlook.

Update 11/7/2022: it turned out that the event is caught but
I am tryning to catch the item type by the below method and inline item does not detected as an item.

itemtype = Application.ActiveWindow().CurrentItem.Class;

2

Answers


  1. I can confirm that the ItemSend event is fired for all outgoing emails in Outlook, including inline responses. To make sure I’ve just created a sample VSTO add-in and placed your code there. Everything works correctly when I reply to items in-place. Try to declare the Application object at the class level. But I think everything should work as is now.

    Outlook.Application application = null;
    
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                application = Globals.ThisAddIn.Application;
                application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
                
            }
    
    

    You may consider subscribing to the Explorer.InlineResponse event which is fired when the user performs an action that causes an inline response to appear in the Reading Pane. So, you may get the item composed and do whatever you need (subscribe to the Send event).

    Be aware, a low level API such as Extended or Simple MAPI doesn’t trigger the ItemSend event in Outlook – only actions made in the Outlook object model or made manually can trigger the event.

    Login or Signup to reply.
  2. It should work in all cases, but Outlook disables most OOM events for the items created using Simple MAPI or from the "mailto:" links. Is that the case?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search