0
votes

I have created a simple VSTO outlook add-in whose purpose is to automatically set the subject of mail when reply button is clicked. I've added an EventHandler, Outlook.ItemEvents_10_ReplyEventHandler on MailItem. So whenever reply button is clicked, a callback function is triggered, let's say func() from ThisAddIn.cs class. This much works fine.

Then, I generated a button in context menu using Ribbon. Currently, when I click on that button, it displays a MessageBox indicating that onAction for this control is working and the function for displaying the MessageBox is written in MyRibbon.cs class. Now, I'm not getting how can I call func() of ThisAddIn.cs class and pass object in it(in this case MailItem) from onAction attribute defined in xml file, which I used to render button in context menu?
I've tried to refer this (https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/ee692172(v=office.14)?redirectedfrom=MSDN) document but I can't the project mentioned in it.

1

1 Answers

0
votes

IRibbonControl object will be passed as a parameter to your event handler. Cast IRibbonControl.Context as either Inspector (use Inspector.CurrentItem then) or as Explorer (use Explorer.Selection collection or Explorer.InlineResponse)