Search code examples
c#outlookvstoinspector

VSTO Outlook 2010 Cancel Inspector Close


I have seen other posts regarding Outlook 2007 stating that you can't cancel an inspector close event. Is this still true in Outlook 2010 or 2013? If it is possible, how do I do this?

Also, if I can't cancel the close, can I cancel the save?

I am not asking for any logic pertaining to a specific application. I just want to know if there is a line of code that I can pass a bool into or a property that I can set to false to cancel the close event/save event.

Edit: For some clarification, I want to cancel the contact page's close event.


Solution

  • MailItem.Close event passes the Cancel parameter which you can set to true. To prevent an inspector from being closed, you can drop down to the Windows API level and override the Inspector's window proc. You can then intercept (and discard) WM_CLOSE and WM_SYSCOMMNAND Windows messages.