Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture Print event in Outlook Add-in?

I'm working on a C# VSTO 3.0 Outlook Add-in where I need to capture the Print event (When user selects Print option from Outlook to print an Email). I could not find any API in Outlook Object Model which provide access to this event. Is there any way to accomplish this?

like image 919
Kapil Avatar asked Nov 13 '22 06:11

Kapil


1 Answers

If you want to intercept the print command in the backstage view you can take a look at the following article:

http://msdn.microsoft.com/en-us/library/ee691833(office.14).aspx#odc_Office2010Introduction2OutSpaceUI_BackStageUIFAQs

"It is not possible to override these commands from the custom UI XML markup or by using the object model. Using the DocumentBeforeSave event is one alternative, but using that doesn't really change the functionality of the individual commands that show up in the Change File Type gallery in the Backstage. A better solution would be to consider hiding the built-in UI and rebuilding it fully with custom commands."

(the above is about File -> Save As.. but it is pretty much the same case for File -> Print).

So basically you need to add your own command instead the built in. If you are not talking about the Backstage but some older Outlooks where the print command is in menu item / ribbon / command bar, you can also take a look at this article in AddIn Express (I think it will work without their products):

http://www.add-in-express.com/creating-addins-blog/2012/02/27/how-an-office-add-in-intercepts-clicking-a-built-in-control/

The idea there is the same - you find the Id or IdMso of the button / menu item of interest and create new one in order to get to the events.

Hope this helps.

like image 149
Pavel Donchev Avatar answered Nov 16 '22 04:11

Pavel Donchev