0
votes

I want to add my custom ribbon button in the "Report" tab of Outlook. I am able to add a ribbon button in "Home" Tab of Outlook. Here I have attached the image where I want to add my custom ribbon button.

enter image description here

Thanks

2

2 Answers

1
votes

Ribbon XML Code is here,

<ribbon>
    <tabs>
      <tab idMso="TabReadMessage">
        <group id="grpMessageRibbon" Label="My Group">
          <button id="btnTest" Label="My Button" size="large" />
        </group>
      </tab>
    </tabs>    
  </ribbon>

Ribbon XML load based on it's ribbon id.

  public string GetCustomUI(string ribbonID)
        {
            string ribbonXML = String.Empty;

            if (ribbonID == "Microsoft.Outlook.Report")
            {
                ribbonXML = GetResourceText("MicrosoftOutlookReport.xml");
            }

            return ribbonXML;
        }

Thanks

0
votes

The idMso of the built-in tab shown on the screenshot is TabReadMessage. You just need to return an appropriate ribbon XML markup in the GetCustomUI callback.

Microsoft Office applications call the GetCustomUI method to obtain an XML string that defines the user interface of your custom Ribbon.

public class Connect : Object, Extensibility.IDTExtensibility2, IRibbonExtensibility 
... 

public string GetCustomUI(string RibbonID) 
{ 

   StreamReader customUIReader = new System.IO.StreamReader("C:\\RibbonXSampleCS\\customUI.xml"); 

   string customUIData = customUIReader.ReadToEnd(); 

   return customUIData; 
 }

Note, sometimes you need to return the XML markup for different ribbonID values passed as an argument. In that case you will get the onLoad callback invoked (for inspectors too).

    public string GetCustomUI(string ribbonID)
    {
        string ribbonXML = String.Empty;

        if (ribbonID == "Microsoft.Outlook.Mail.Read")
        {
            ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml");
        }

        return ribbonXML;
    }

See Customizing a Ribbon for Outlook for more information.

You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN:

Please remember that by default, if an VSTO add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom Ribbon does not appear, or why a Ribbon appears but no controls appear. See How to: Show Add-in User Interface Errors for more information.