0

I have a custom ribbon which I have to show when a mail selected and also when the mail is opened by double click. I have the button placed correctly when a mail is opened by double click.

How to get the ribbon when a mail is selected? [Mail body is shown in the reading pane].

user2325247
  • 774
  • 1
  • 7
  • 18

1 Answers1

0

First, add an event handler in the startup method:

private void ThisAddIn_Startup(object sender, EventArgs e)
{
    Application.ActiveExplorer().SelectionChange += activeExplorer_SelectionChange;
}

Then, in the event handler, display the ribbon using the ControlId:

void activeExplorer_SelectionChange()
{
        var ribbon = Globals.Ribbons.YourRibbon;
        if (ribbon.RibbonUI != null)
            ribbon.RibbonUI.ActivateTab("YourRibbonControlId");
}

You should set the ControlId in the DesignView of your ribbon!

Stefan Over
  • 5,851
  • 2
  • 35
  • 61