wierd problem when intercepting AttachFile command in Outlook 2013

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

wierd problem when intercepting AttachFile command in Outlook 2013
 
Stan S




Posts: 181
Joined: 2007-09-04
It appears that the problem comes up with 7.4.4067.2005, though could be merely a coincidence.

One of our end users uses a LOTS of plugins that process attachments, including ours. Our plugin intercepts AttachFile command to display its own FileDialog. Some other plugin does that, too.
So on a specific machine, our plugin receives AttachFile command even though it's been processed (and probably canceled) by another plugin. I can see it because dialogs are different.
If I do not process this command, however, Outlook would not display 2nd dialog box.
I am checking .Canceled property on event and it's false.

Could it be that you guys do not process Canceled property on the COM event? Other than that, is there a way to force Outlook to process event from our plugin first?

Thanks,
Stan
Posted 18 Jun, 2014 15:39:52 Top
Andrei Smolin


Add-in Express team


Posts: 15354
Joined: 2006-05-11
Hello Stan,

I've created two add-ins intercepting the AttachFile command. In the add-ins' code the command is cancelled if a Ribbon check box (each add-in shows a checkbox) is selected:

private void adxRibbonCommand1_OnAction(object sender, IRibbonControl control, bool pressed, ADXCancelEventArgs e) {
    System.Diagnostics.Debug.WriteLine("!!! MyAddin153. adxRibbonCommand1_OnAction");
    e.Cancel = adxRibbonCheckBox1.Pressed;
    System.Diagnostics.Debug.WriteLine("!!! MyAddin153. e.Cancel=" + e.Cancel.ToString());
}


In addition, the add-ins print some debug info at startup. Here's what I have:

Loading
[5164] !!! MyAddin152. AddinModule_AddinInitialize
[5164] !!! MyAddin153. AddinModule_AddinInitialize
[5164] !!! MyAddin152. AddinModule_OnRibbonBeforeLoad
[5164] !!! MyAddin153. AddinModule_OnRibbonBeforeLoad
[5164] !!! MyAddin152. AddinModule_OnRibbonBeforeLoad
[5164] !!! MyAddin153. AddinModule_OnRibbonBeforeLoad
Clicking the AttachFile button
[5164] !!! MyAddin153. adxRibbonCommand1_OnAction
[5164] !!! MyAddin153. e.Cancel=False
[5164] !!! MyAddin152. adxRibbonCommand1_OnAction
[5164] !!! MyAddin152. e.Cancel=False

If I unregister MyAddin153, change its ProgId from "MyAddin153.AddinModule" to "AAAAAA.AddinModule" and register the add-in anew, I get the following results:

Loading
[5164] !!! MyAddin153. AddinModule_AddinInitialize
[5164] !!! MyAddin152. AddinModule_AddinInitialize
[5164] !!! MyAddin153. AddinModule_OnRibbonBeforeLoad
[5164] !!! MyAddin152. AddinModule_OnRibbonBeforeLoad
[5164] !!! MyAddin153. AddinModule_OnRibbonBeforeLoad
[5164] !!! MyAddin152. AddinModule_OnRibbonBeforeLoad
Clicking the AttachFile button
[5164] !!! MyAddin152. adxRibbonCommand1_OnAction
[5164] !!! MyAddin152. e.Cancel=False
[5164] !!! MyAddin153. adxRibbonCommand1_OnAction
[5164] !!! MyAddin153. e.Cancel=False

That is, the add-ins load in the alphabetical order of their ProgIds. They handle a Ribbon command in the reverse order.

Testing these add-ins shows: if one add-in cancels the command, the other one cannot "uncancel" the command.

The only question remains: if the first add-in cancels the command, would it be possible for the other add-in to find this out? The current Add-in Express version cannot answer this question as it sets the Cancel parameter to false before your code is invoked. To get the answer we've debugged the corresponding fragment of the Add-in Express code. The answer is No, an add-in handling a given Ribbon command cannot find out whether another add-in cancels the command or not.

Hope this helps.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Jun, 2014 04:51:28 Top
Stan S




Posts: 181
Joined: 2007-09-04
Hi Andrei, that makes sense, thank you for detailed explanation!
(even though it can't magically resolve the problem, but it's what it is, we'll have to work through it with the customer)

Stan
Posted 19 Jun, 2014 10:18:23 Top
Andrei Smolin


Add-in Express team


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

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Jun, 2014 10:38:50 Top