Adding a custom context menu item to Outlook 2013



One of the most common feature provided by VSTO is Office UI Customization and when we talk about UI Customization that’s mean most of the time:

  • Adding a Button to an existing Ribbon
  • Adding a new Ribbon
  • Adding an context menu item
  • Adding a custom Task Pane
  • Adding a custom Form Region

In this article, I’m going to show you how to add a new item to the built-in Outlook 2013 context menu. Just remember that: by following the next steps you can add a custom item to any of Office Suite components contextual menu.

I’ll suppose that you’ve already created a new empty Outlook 2013 Add-in Project so let’ s add a new XML Ribbon


Now let’s change the content of that XML file to this code snippet

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="" onLoad="Ribbon_Load">
    <contextMenu idMso="ContextMenuMailItem">
      <button id="SynchronizeMailItem" onAction="ShowMessageClick" getImage="GetIcon" getLabel="GetSynchronisationLabel"/>

each context menu item must have an isMso, this ID specifies which control our context menu item will be connected to. In this case I chose to bind our newly created context menu item to the the ContextMenuMailItem control , so whenever you right click on any mail you’ll get this context menu. These Ids can be one of the known Ids given by Microsoft so if you want to get the whole list of the Office UI Control Identifiers please visit this link: Office Fluent UI Control Identifiers

When outlook try to render our context menu item, it will try to get its properties from the specified functions in getImage and getLabel Attributes. Let’s add these methods to the
Ribbon Class (in our case it’s called Ribbon1)

        public Image GetIcon(Office.IRibbonControl control)
            return Resources.icon;

        public string GetSynchronisationLabel(Office.IRibbonControl control)
            return "Synchronize";

        public void ShowMessageClick(Office.IRibbonControl control)
            MessageBox.Show("You've clicked the synchronize context menu item","Information",MessageBoxButtons.OK,MessageBoxIcon.Information);

Now, In order to get this example ready to be loaded inside Outlook 2013 we have to add a reference to our XML Ribbon inside the ThisAddIn class

        protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            return new Ribbon1();

Running this project will load our Add-in into Outlook 2013, Now right click on any received email and you’ll see that our context menu item is right there ready for action



Adding a custom menu Item to Outlook 2013 or any other Office Suite component is very direct you need to just remember to consult the official Office Fluent UI Control Identifiers from the MSDN website.


2 thoughts on “Adding a custom context menu item to Outlook 2013

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s