Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7834259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:06:19+00:00 2026-06-02T13:06:19+00:00

We setup a custom context menu when you right click an email in Outlook

  • 0

We setup a custom context menu when you right click an email in Outlook like so:

        private void _application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Interop.Selection Selection)
        {
                var contextButton = (Office.CommandBarButton)CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Temporary: true);
                contextButton.Visible = true;
                contextButton.Caption = "&My Context Menu";
                contextButton.Click += MyContextMenu_Click;
        }

This method is subscribed to Application.ItemContextMenuDisplay.

It’s working fine, except that occasionally our event gets fired multiple times. It happens when you right-click quickly on different emails.

Then it makes me wonder, when is a good place to cleanup my temporary context menu item? I need to unsubscribe the C# event somewhere. Where is the intended place to do that? (I would also think we might need to call Marshal.ReleaseComObject)

We are using VSTO and the Outlook 2010 project template in Visual Studio. I haven’t found many good examples of customizing the context menu, in general.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:06:24+00:00Added an answer on June 2, 2026 at 1:06 pm

    This quirkiness is probably why in Outlook 2010, Microsoft is moving more towards the Ribbon XML context menu customizations in favor of the Outlook 2007-style of CommandBars. See related SO post.

    As for cleaning up resources used by the CommandBars, you would need to attach to the Application.ContextMenuClose event to free up resources and unsubscribe your listener. See related SO post on disposing Outlook Context Menus.

    You should refactor your code to utilize the newer Ribbon XML interface to avoid CommandBars.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to setup a custom attribute like the following: [AttributeUsageAttribute(AttributeTargets.Method)] public sealed
I setup custom CSS class for array of dynamic TextBoxes (inputs as HTML) so...
I'm trying to setup custom validation for a checkbox. I have 7 checkboxes each
How can I setup custom sorting method for a QTableView , or for the
Can I setup a custom MIME type through ASP.NET or some .NET code? I
I'm looking to setup a custom route which supplies implicit parameter names to a
I am trying to setup a custom attribute in C# to set whether a
At the moment I have setup a custom ok cancel dialog with a drop
I'm using nopCommerce 2.3 and trying to setup a custom Area but the area
Is it possible to have nested set capabilities in this somewhat custom setup? Consider

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.