1

I have an outlook addin code for when user right clicks on any email the addin option shows up in the right click menu. This happens for Outlook 2007 and Outlook 2010 but when I install the addin in Outlook 2013 the option does not show up in the right click menu.

here is my code :

Application.ItemContextMenuDisplay += ApplicationItemContextMenuDisplay; 

void ApplicationItemContextMenuDisplay(Office.CommandBar commandBar, Selection selection)
        {
            var cb = commandBar.Controls.Add(Office.MsoControlType.msoControlButton,missing, missing, missing, true) as Office.CommandBarButton;
            if (cb == null) return;
            cb.Visible = true;
            cb.FaceId = 1675;
            cb.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;                                      
            cb.Click += new Office._CommandBarButtonEvents_ClickEventHandler(_oAddEmail_Click);
            ConvergeCRMSetting settings = StateManager.current.CRMSettings;

            if (selection.Count == 1 && selection[1] is Outlook.MailItem)
            {
                var item = (MailItem)selection[1];                         
                string subject = item.Subject;

                cb.Caption = "Add Email To ConvergeHub";
                cb.Enabled = true;                                        

            }
            else
            {
               cb.Enabled = false;
            }
            bool bflag = false;
            if (settings.Verified == true && settings.Active == true)
            {
                bflag = true;
            }
            switch (Convert.ToInt16(settings.Sd))
            {
                case 0:
                    cb.Enabled = false;
                    break;
                case 1:
                    cb.Enabled = bflag;
                    break;
                case 2:
                    cb.Enabled = bflag;
                    break;
                case 3:
                    //rbManual.Checked = true;
                    break;
                default:
                    break;
            }

        }

What must I do to make the addin option visible in Outlook 2013 ? Any suggestions ?

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Mainak
  • 469
  • 3
  • 9
  • 33
  • Did you update the Reference .dll to the newest version? We use Excel Interop at work and upgrading from Office 2010 to 2013 has created some serious issues. – Sean Cox Nov 20 '15 at 05:45
  • Did you mean The Reference.dll or the outlook interop reference ? In case of outlook interop reference , I did not upgrade it because in that case I have to upgrade for each new version that comes to the market. – Mainak Nov 20 '15 at 06:43

3 Answers3

1

Command bars have been deprecated - you have to use IRibbonExtensibility to customize context menus for Outlook 2013+:

https://msdn.microsoft.com/EN-US/library/ff865324.aspx

Eric Legault
  • 5,706
  • 2
  • 22
  • 38
1

Eric is right on the depreciation of the command bar since Office 2013. And it has been a good thing I think.

I would recommend to use:

  1. the Ribbon designer available with VSTO using Visual Studio. It has a friendly interface to create ribbons instead of command bars. Attaching events works as you are used to from the Windows Forms or WPF designer.

    Useful reading on MSDN here.

  2. the Fluent UI and IRibbonExtensibility to bind to context menus, etc.

    Useful reading on MSDN here and here.

Community
  • 1
  • 1
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
0

You could use an old approach (CommandBars) in Outlook 2007. But starting from Outlook 2010 the Fluent UI is used for customizing context menus in Outlook. You can read more about that in the following articles:

The Fluent UI (aka Ribbon UI) is described in the following articles:

The Ribbon designer doesn't provide anything for context menus. You will need to use a ribbon XML markup for customizing context menus.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45