Welcome to MSDN Blogs Sign in | Join | Help

MenuItem for Outlook ContextMenu

Last project I was working on had lot of customisation for Outlook 2003 and its integration with MOSS (Sharepoint 2007). Its altogether a unique experience working with Outlook object model and creating a custom outlook plugin.
 
Following is a small snippet for adding or manipulating context menu within outlook explorer.
 

//get outlook explorer object

private Outlook.Explorer actExplorer = this.ApplicationObject.Application.ActiveExplorer();

//get instance of all command bars

private CommandBars cmdBars = actExplorer.CommandBars;

cmdBars.OnUpdate += new _CommandBarsEvents_OnUpdateEventHandler(CommandBars_OnUpdate);

/// <summary>

/// Implements the OnUpdate event for outlook command bars.

/// </summary>

private void CommandBars_OnUpdate()

{

      foreach (CommandBar cmdBar in actExplorer.CommandBars)

      {

            if (cmdBar.Name == "Context Menu")

            {

                  //remove protection

                  MsoBarProtection oldProtection = cmdBar.Protection;

                  cmdBar.Protection = 0;

 

                  //create custom menu item

                  CommandBarButton checkInMenuItem = (CommandBarButton)cmdBar.FindControl(MsoControlType.msoControlButton, Type.Missing, "Custom Menu", Type.Missing, Type.Missing);

                  if(checkInMenuItem == null)

                  {

                        checkInMenuItem = (CommandBarButton)cmdBar.Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);

                        checkInMenuItem.Caption = "Custom Menu";

                        checkInMenuItem.Click += new _CommandBarButtonEvents_ClickEventHandler(checkInMenuItem_Click);

                  }

 

                  //set protection level

                  cmdBar.Protection = oldProtection;

            }

      }

}

Published Friday, November 02, 2007 6:17 AM by manish_mgsi

Comments

# MSDN Blog Postings &raquo; MenuItem for Outlook ContextMenu

Friday, November 02, 2007 3:11 AM by MSDN Blog Postings » MenuItem for Outlook ContextMenu
Anonymous comments are disabled
 
Page view tracker