Powered by Blogger.

Sunday, February 23, 2014

How to add menus in outlook menu bar using C#.net object model?

In this post we will discuss how to add menus in outlook menu bar using C#.Net object model. Also you can check out my previous posts on:

- Create a database by command in sql server 2008

- Set Maximum length for multiline textbox in asp.net

- Show confirmation message in gridview for delete in Asp.net

Here is the code to add menubar in outlook plugin application using c#.net object model.

private Office.CommandBar menuBar;
        private Office.CommandBarPopup newMenuBar;
        private Office.CommandBarButton buttonFeedback;

And in the ThisAddIn_Startup you can write the following lines of code that will show the menu  in the menu bar.

 menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
    newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(
                    Office.MsoControlType.msoControlPopup, missing,
                    missing, missing, true);
 if (newMenuBar != null)
                    newMenuBar.Caption = "My&Menu";
                    newMenuBar.Tag = menuTag;
 buttonFeedback = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                    buttonFeedback.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    buttonFeedback.Caption = "Customer &Feedback Option";
//Face ID will use to show the ICON in the left side of the menu.
                    buttonFeedback.FaceId = 3737;
 newMenuBar.Visible = true;
//You can also add event handlers for the menus.
                buttonFeedback.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(buttonFeedback_Click);


Post a Comment