Search code examples
c#outlookvstooutlook-addinribbonx

How to add a ribbon group to both Outlook inspector windows and the inline response contextual menu?


I want to add the same controls to the ribbon whenever an email is being composed, regardless of whether the email is popped out in an inspector or in an inline response. I can do this by duplicating the same XML in two places, of course, like this:

<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon>
        <tabs>
            <tab idMso="TabMail">
                (my ribbon group - inspector)
            </tab>
        </tabs>
        <contextualTabs>
            <tabSet idMso="TabComposeTools">
                <tab idMso="TabMessage">
                    (my ribbon group again - inline response)
                </tab>
            </tabSet>
        </contextualTabs>
    </ribbon>
</customUI>

But is there any way to reuse the same ribbon group twice to avoid this repetition?


Solution

  • No, you need to define tabs separately. But there is no need to return the whole custom UI XML at once.

    Actually you need to return an appropriate ribbon XML markup depending on the value passed to the GetCustomUI method of the IRibbonExtensibility interface. The RibbonID string parameter indicates the context where the custom UI will be shown (inspector - outlook item types, explorer and etc.). So, you just need to return an appropriate Ribbon UI markup depending on the context passed.