Making a Custom Ribbon Appear Only for a Custom Outlook Form (Norm Estabrook)

  • Comments 5

Many of you have posted questions to the VSTO Forum about how to make custom tabs, groups and controls appear only in cases where the user opens a custom form in Outlook.

The reason why that is difficult to accomplish is because there is no way to specify the names of custom forms in the Ribbon Designer. You can only specify inspector window types.

So if I set the RibbonType property of the Ribbon to “Microsoft.Outlook.Mail.Compose”,  then the Ribbon controls appear for all new mail items including items that I create by using a custom mail form. So how can I make sure that the Ribbon controls only appear in my custom mail form?

One possible workaround is to show and hide controls based on the message class of an Outlook form. It seemed to work for me and here is how I did it.

In the Ribbon designer, set the Visible property of your custom controls to false. At this point, those controls will not appear in any Outlook form custom or otherwise.

Next, add a property to the ThisAddIn class that stores the name of a custom message class as follows:

private string strMessageClass = "";
public string MessageClass
        return strMessageClass;
        strMessageClass = value;

Create an event handler for the NewInspector event. This event is raised every time a new Outlook inspector is open. The item that opens in the inspector has a message class name. For example, if you open a standard mail item, the message class name of the item is “IPM.Note”. A custom form based on a standard email form might have the message class name “IPM.Note.MyCustomForm”.

In the event handler, set your custom string property to the message class name of the open item. Here is an example:

private Outlook.Inspectors inspectors;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
    inspectors = this.Application.Inspectors;
    inspectors.NewInspector +=
        new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler


void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    Outlook.MailItem tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem;
    if (tmpMailItem != null)
        MessageClass = tmpMailItem.MessageClass;

In the load event of your Ribbon class, check your custom string property to determine the message class of the item that is attempting to load your custom Ribbon. If the name matches the name of your custom message class, you can show the controls on your custom Ribbon. Here is an example:

private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
    if (Globals.ThisAddIn.MessageClass == "IPM.Note.Norm")
        group1.Visible = true;
        Globals.ThisAddIn.MessageClass = "";

  • PingBack from

  • This blog explains how to show/hide my custom ribbon bits. How do I selectively hide base bits of a ribbon?

  • Do you mean the built-in tabs of the Ribbon?  You could set the StartFromScratch property of a custom Ribbon to False.

  • Thank you for blog.

    Ribbon1 ribbon = sender as Ribbon1;

    if (ribbon != null) {

    Microsoft.Office.Interop.Outlook.InspectorClass inspector = ribbon.Context as Microsoft.Office.Interop.Outlook.InspectorClass;



    Why you don't used like this?

  • What do you set the  RibbonType property to for this example?  I am trying to implement this, and have your code example exactly.  The Ribbon shows up for me, with my new custom controls for the MailItem (standard) but not for the custom one (IPM.Note.Norm).  I have it set as:

    this.RibbonType = "Microsoft.Outlook.Mail.Read";

    To me it makes sense to not check any of the RibbonTypes .... but maybe it needs to be something?

Page 1 of 1 (5 items)

Making a Custom Ribbon Appear Only for a Custom Outlook Form (Norm Estabrook)