none
Add ContextMail Item Outlook 2013 RRS feed

  • Question

  • Hello All,
    I want to add One CustomContextMenu Item in Mail display Outlook 2013.
    For thst i tried Following Approaches but it didn't work.i am not able to see any context item


    Approach : 1

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {

                this.Application.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(Application_ItemContextMenuDisplay);

            }

            private void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
            {
                Outlook.MailItem selectedMailItem = Selection[1] as Outlook.MailItem;
                this.CustomContextMenu(CommandBar, Selection);
            }

            private void CustomContextMenu(Office.CommandBar CommandBar, Outlook.Selection Selection)
            {

                Office.CommandBarButton customContextMenuTag = (Office.CommandBarButton)CommandBar.Controls.Add

                (Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);

                customContextMenuTag.Click += new

                Office._CommandBarButtonEvents_ClickEventHandler(customContextMenuTag_Click);

                customContextMenuTag.Caption = "My Context Menu";

                customContextMenuTag.FaceId = 351; //displays the image for the menu item

                customContextMenuTag.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption;

            }

            private void customContextMenuTag_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
            {

                System.Windows.Forms.MessageBox.Show("My Custom Menu Item Clicked");

            }

    Approach 2:

    Add one Ribbion.xml and add xml 
     <contextMenu idMso="ContextMenuMailItem">
          <button id="MyContextMenuMailItem"
              label="ContextMenuMailItem"
              onAction="OnMyButtonClick"/>
        </contextMenu>


    Above both approaches not work for me 
    can someone help me.
    I am using Outlook2013.
    • Edited by Mayank_55 Thursday, March 17, 2016 6:21 AM
    Thursday, March 17, 2016 6:16 AM

Answers

All replies

  • Hello,

    Where did you paste the Ribbon XML markup shown above?

    Command bars were deprecated and are not used any longer. You need to use the Fluent UI for customizing context menus in Office 2010 and later. See Customizing Context Menus in Office 2010 for more information. Also take a look at the Extending the User Interface in Outlook 2010 article.

    • Marked as answer by Mayank_55 Friday, March 18, 2016 4:44 AM
    Thursday, March 17, 2016 11:45 AM
  • Mayank_55,

    The ribbon approach is correct. The same question asked by Eugene ... "Where did you put it?". Markup provided should go to "contextMenus" section of "customUI" node as follow:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
      <contextMenus>
        <contextMenu idMso="ContextMenuMailItem">
          <button id="cmdGetMessageStatus" getVisible="GetVisible" getLabel="GetLabel" onAction="OnButton"/>
        </contextMenu>
      </contextMenus>
    </customUI>


    Slava Ivanov

    Thursday, March 17, 2016 2:57 PM