Handling Reply All option in right-click popup menu in Outlook 2019

Add-in Express™ Support Service
That's what is more important than anything else

Handling Reply All option in right-click popup menu in Outlook 2019
How do I handle the Reply All option when I right-click on an email in the inbox? 
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
I've managed to handle all the Reply All paths in Outlook 2019 except for one. If you right-click on an unselected email in the inbox, one of the options in the popup menu is Reply All. I'm not sure which of the ADXOutlookAppEvents I'm supposed to intercept - is it ItemContextMenuDisplay?

If that is the right event, how do I use one or more of the three parameters (object sender, object commandBar, object target) to get the information from the mail?

If that's not the right event, which one is?
Posted 30 Jun, 2022 04:45:01 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Roberto,

The ItemContextMenuDisplay event shouldn't be used in Outlook 2016+; this event doesn't fire for me; Microsoft declared it deprecated.

Instead, you put an ADXRibbonCommand onto the designer of the add-in module. Set the component as follows:
- IdMso = ReplyAll
- Ribbons = {must include OutlookExplorer}

Then handle the ADXRibbonCommand.OnAction event.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 30 Jun, 2022 04:59:07 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

Thank you. I also found the "Add-in Express .NET.CHM" file, and read the section for "How to intercept or disable a built-in Ribbon control", which agrees with your reply. However, I'm still unsure of how to use the first three parameters of OnAction (object sender, IRibbonControl control, bool pressed, ADXCancelEventArgs e) to handle my code. Am I supposed to check if the control matches the Reply All button in the popup menu?

Another thought: as I said in the first message, I've handled the case where the message in the inbox has been selected through the adxOutlookAppEvents_ExplorerSelectionChange event. That event handler connects my item events class to the message. But if I right-click on an unselected message, then the event handler isn't used, so the message isn't connected to my item events class. Am I supposed to handle the message directly in the OnAction code?

Robert
Posted 30 Jun, 2022 14:23:41 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Robert,

If you intercept the ReplyAll command in the Explorer window only (i.e. ADXRibbonCommand.Ribbons is OutlookExplorer) then you don't do anything else. If there are several Ribbons, you might want to check if the Reply All command is clicked in the Explorer or Inspector window; see section Determining a Ribbon control's context; see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Roberto Esguerra writes:
Am I supposed to check if the control matches the Reply All button in the popup menu?


No. You've already specified the command to intercepts; see ADXRibbonCommand.IdMso. You don't need the 'pressed' parameter.

Roberto Esguerra writes:
Am I supposed to handle the message directly in the OnAction code?


There's the PropertyChanging event on all Ribbon controls. The event is triggered when Office looks for a value of a control's property; e.g. Visible, Caption, Enabled, etc.You add such a control to the context menu where Reply All is shown and make the control hidden. Now, when your control's PropertyChanging event is triggered - I suppose Office will look for e.PropertyType == ADXRibbonControlPropertyType.Visible - you connect your event class to the selected mail: get the context object, cast it to Outlook.Selection and see Selection[1].

Here's a citation from the Add-in Express manual:

Ribbon context menus (Office 2010+). To add a custom control to a Ribbon-based context menu, use the ADXRibbonContextMenu component. It allows adding custom Ribbon controls to several context menus in the specified Ribbons. The screenshots below show an ADXRibbonContextMenu adding a button to a few context menus in ExcelWorkbook, WordDocument and PowerPointPresentation Ribbons. To specify the context menus, to which the button will be added, you use the editor of the ContexMenuNames property of the component. To find out what name a context menu has, use the add-in project that we describe on our blog (https://www.add-in-express.com/creating-addins-blog/2015/04/15/creating-office-context-menu-addin/).

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 01 Jul, 2022 06:25:10 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

Based on your reply on June 30, I wanted to make sure there is no misunderstanding of which control I'm trying to trap. It's this one (I hope you can see the image from the Google Drive link).

[img]https://drive.google.com/file/d/1Ww6_Mf4dpmTfnqoum242sZk6LxqfGSGs/view?usp=drivesdk[/img]

I must admit I'm still unclear on what I need to do.
Posted 05 Jul, 2022 17:59:24 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Robert,

The ADXRibbonCommand component allows intercepting Ribbon commands. Put such a component onto the add-in module and set its properties:
- IdMso - the Id of the Ribbon command to intercept; in your case this is 'ReplyAll' (without quotes).
- Ribbons - a list of Ribbon views (distinguishable sets of Ribbons controls); yours is OutlookExplorer - because your screenshot shows an Outlook Explorer window.

After that you need to handle the OnAction event of the ADXRibbonCommand component.

Please let me know whether this works for you.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jul, 2022 03:28:14 Top
Roberto Esguerra




Posts: 22
Joined: 2022-01-31
Andrei,

I had to read the article "Determining a Ribbon control's context" in the CHM to fully understand what you were suggesting I do. The combination of your earlier messages and that article did the trick. I am now handling the Reply All button in the popup dialog.

Thanks for your help.

Robert
Posted 08 Jul, 2022 00:28:55 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
You are welcome!

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Jul, 2022 03:22:15 Top