none
Detecting the send event in Outlook addin RRS feed

  • Question

  • I'm trying to write an Outlook AddIn app in C# using Visual Studio 2012.  I need to detect when the send button is clicked in a current email.  I'll want to perform some actions after the send button has been clicked.   

    I assume an event handler needs to be created, but I'm not sure where- at the item level, or application level.  I created a mail item object with Outlook.MailItem publicItem = (Outlook.MailItem).this.OutlookItem.  It seems like I should be detecting publicItem.send but I'm not clear on how and where to use event handlers in this case.  

    I added a checkbox, and Visual Studio created publicCheckBox_Changed(object sender, EventArgs e) for me.  To check if the box was checked, I used  'if(publicCheckBox.checked) { do stuff }.   Is detecting the send event similar? 

    I'm new to c# and Outlook Addins, and fairly new to coding.  

    Thanks for your help. 

    Wayne


    Thursday, January 29, 2015 8:46 PM

Answers

  • Hello Wayne,

    In the check box Clicked event you can add a user property to the MailItem (see UserProperties.Add). Then in the ItemSend event ( see the Application class) handler you can check out the property value - whether it is set or not. Be aware, the Cancel parameter passed to ItemSend event handler allows to prevent the item from sending.

    Thursday, January 29, 2015 9:22 PM