Search code examples
c#vstooutlook-addinribbon

VSTO Outlook custom ribbon doesn't show when creating new email


I am working on creating a custom function that is available when sending an email. I was able to follow several tutorials regarding how to make the ribbon item. By default I am able to get it to show on the main window of outlook. However, I do not want it to show here; I only want to show it when creating a new email. I do have the ribbon types 'Microsoft.Outlook.Explorer', 'Microsoft.Outlook.Mail.Read', and 'Microsoft.Outlook.Mail.Compose' selected but that doesn't seem to make a difference. I have selected all possible 'Outlook' ribbon types as a test and that doesn't work either. I did find that you have to set the correct 'OfficeId'(idMso) for the tab object, so I am suspect this is the issue. However, I can't find this information anywhere to show my options. There seem to be links to old articles which have been removed or deleted. I found another article suggesting to change the default of 'TabHome' to 'TabMail' which did help in getting the ribbon to show in the main outlook window.

Any suggestions are welcome.

EDIT to include the ribbon xml

<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon>
        <tabs>
            <tab idMso="TabMail">
                <group id="group1" label="Test Group">
                    <button id="button1" label="Hello" showImage="false" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>


Solution

  • That is ribbon for an explorer. If you want an inspector, you need something like the following. It needs to be returned from your implementation of GetCustomUI()

    public string GetCustomUI(string ribbonID)
    {
      if (string.Compare(ribbonID, "Microsoft.Outlook.Mail.Compose", true) == 0)
      {
         return theRibbonXml;
      }
      else
      {
        return null;
      }
    }
    

    ...

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
        <ribbon>
            <tabs>
                <tab idMso="TabNewMailMessage">
                    <group id="group1" label="Test Group">
                        <button id="button1" label="Hello" showImage="false" />
                    </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>