none
c# add a Context menue in Outlook 2013 RRS feed

  • Question

  • Hi,

    using Visual Studio 2012 and c#. How do i add a context menue item in Outlook 2013? In Outlook 2010

    this was working like this:

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

    This does not work in Outlook 2013, because the Event "ItemContextMenuDisplay" does not longer exist.
    Please how do i add a context menu for Outlook 2013?

    Thanks Best Regards
    WW

    Tuesday, April 2, 2013 11:07 AM

Answers

  • In Outlook 2013 the recommended way to handle context menu clicks is using ribbon XML for the Explorer object and handling the callbacks for those context menu items, not using the now deprecated CommandBars interfaces.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Quist Zhang" <=?utf-8?B?UXVpc3QgWmhhbmc=?=> wrote in message news:856d89e0-592d-46fa-8c71-f3068732d52f...

    Hi WiglWagl,

    Thank you for posting in the MSDN Forum.

    The event is still exist in Outlook 2013. The code generated by intellisense is as follows

    namespace OutlookAddIn1
    {
        public partial class ThisAddIn
        {
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.ItemContextMenuDisplay += Application_ItemContextMenuDisplay;
            }
    
            void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
            {
                
            }
    
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #region VSTO generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }
            
            #endregion
        }
    }

    After you typed this.Application.ItemContextMenuDisplay, you'll only need to press tab to generate the event handler.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Ken Slovak MVP - Outlook
    Thursday, April 4, 2013 3:06 PM
    Moderator
  • Hi WiglWagl,

    Thank you for posting in the MSDN Forum.

    The event is still exist in Outlook 2013. The code generated by intellisense is as follows

    namespace OutlookAddIn1
    {
        public partial class ThisAddIn
        {
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.ItemContextMenuDisplay += Application_ItemContextMenuDisplay;
            }
    
            void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
            {
                
            }
    
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #region VSTO generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }
            
            #endregion
        }
    }

    After you typed this.Application.ItemContextMenuDisplay, you'll only need to press tab to generate the event handler.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 4, 2013 1:14 PM
    Moderator

All replies

  • Hi WiglWagl,

    Thank you for posting in the MSDN Forum.

    The event is still exist in Outlook 2013. The code generated by intellisense is as follows

    namespace OutlookAddIn1
    {
        public partial class ThisAddIn
        {
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.ItemContextMenuDisplay += Application_ItemContextMenuDisplay;
            }
    
            void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
            {
                
            }
    
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #region VSTO generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }
            
            #endregion
        }
    }

    After you typed this.Application.ItemContextMenuDisplay, you'll only need to press tab to generate the event handler.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 4, 2013 1:14 PM
    Moderator
  • In Outlook 2013 the recommended way to handle context menu clicks is using ribbon XML for the Explorer object and handling the callbacks for those context menu items, not using the now deprecated CommandBars interfaces.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Quist Zhang" <=?utf-8?B?UXVpc3QgWmhhbmc=?=> wrote in message news:856d89e0-592d-46fa-8c71-f3068732d52f...

    Hi WiglWagl,

    Thank you for posting in the MSDN Forum.

    The event is still exist in Outlook 2013. The code generated by intellisense is as follows

    namespace OutlookAddIn1
    {
        public partial class ThisAddIn
        {
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.ItemContextMenuDisplay += Application_ItemContextMenuDisplay;
            }
    
            void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
            {
                
            }
    
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #region VSTO generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }
            
            #endregion
        }
    }

    After you typed this.Application.ItemContextMenuDisplay, you'll only need to press tab to generate the event handler.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Ken Slovak MVP - Outlook
    Thursday, April 4, 2013 3:06 PM
    Moderator
  • The OP is unable to handle the event, there is no issue in writing the event; It will never fire for Outlook 2013 (I tried above code in outlook 2013). So above post is not helping

    Ki9

    Friday, October 10, 2014 2:13 PM
  • Could you please be more specific? What Ribbon XML markup do you use for context menu?

    See Customizing Context Menus in Office 2010 for more information.

    Friday, October 10, 2014 2:20 PM
  • What event will never fire? How are you trying to handle the event?

    If this is being attempted using the Application.ItemContextMenuDisplay() event that's the incorrect way to do it. That event has been deprecated and should not be used in either Outlook 2010 or 2013.

    If the ribbon XML callback is being used it most certainly does work. I use it myself in my own code.


    Ken Slovak MVP - Outlook

    Friday, October 10, 2014 2:34 PM
    Moderator