none
Referring to an Outlook Ribbon item but not from an Add-In RRS feed

  • Question

  • Hi,

    I have a VS2010 application that creates and sends an Outlook 2010 e-mail using VSTO however due to some recent changes in regulation we are now required to send all e-mails using a specific secure method.

    The organisation that offer the encryption service provides an add-in that adds a button to the Message tab in the ribbon displayed by the mail item inspector however they provide no programmatic interface to be able to automate sending e-mails.  As many of our e-mails are templated and we record when they are sent, it is not practical to simply display the mail item and expect the user to click the button to send it. However I cannot find any way of automating clicking this button or even referring to it as all examples that I can find assume that the code is being executed from an add-in which in this case it isn't.

    Can anyone help?  I'm pretty new to VSTO.

    Monday, February 11, 2013 5:01 PM

Answers

  • If you know from UI which button must be clicked to invoke their functionality then simply access Inspector.CommandBars property which expose all command bars (and their buttons) - iterate or use Find to find your button and invoke Click on it.
    Tuesday, February 12, 2013 9:16 AM

All replies

  • if they provide no API access to their functionality you are on your own - try myabe to discover how they detect if mail should be encrypted using their code, maybe they just set up some user property or mapi property. If not, then your only option is to automate outlook using SendKeys or Accesability API to mimic user pressing their button.
    Monday, February 11, 2013 6:38 PM
  • If using Redemption is an option, you can try to use Safenspector.Ribbon to select the appropriate tab and simulate a mouse click on the control: http://www.dimastr.com/redemption/SafeRibbonControl.htm

    Note that the message needs to be displayed to be able to access the inspector Ribbons.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Monday, February 11, 2013 7:54 PM
  • @DamianD

    Thanks for your reply.

    There is no detection on their part, the user simply clicks one button to send the mail using their service and the usual send button to send it as normal.

    I'm more than happy to look at the Accessibilty API but I think my first problem is programmatically identifying exactly which button needs to be clicked.  For instance if I could get the window handle of the button that would be a good starting point for me but I'm not sure whether or how it's exposed.  Spy++ isn't particularly helpful in this regard.  I can identify the button by caption if I had this property available to me.

    If this was an addin I would have access to Globals.Ribbons but I can't seem to find how to refer to the ribbons collection outstide of an AddIn due to Globals not being available or my ignorance as to how to reference it.


    • Edited by supergills Tuesday, February 12, 2013 8:41 AM
    Tuesday, February 12, 2013 8:28 AM
  • @Dmitry:

    Thanks for your reply.

    I'll certainly look into Redemption as an option as I hadn't heard of it and it looks very interesting.

    Tuesday, February 12, 2013 8:41 AM
  • If you know from UI which button must be clicked to invoke their functionality then simply access Inspector.CommandBars property which expose all command bars (and their buttons) - iterate or use Find to find your button and invoke Click on it.
    Tuesday, February 12, 2013 9:16 AM
  • Is this can be done for custom button? If so how will we find the control Id to pass as a parameter to Findcontrol method of commandbarbutton object?
    Thursday, March 24, 2016 2:21 PM