简体   繁体   English

外接程序代码可在Outlook 2007和2010中使用,但不能在Outlook 2013中使用

[英]Addin Code Working in outlook 2007 and 2010 but not in outlook 2013

I have an outlook addin code for when user right clicks on any email the addin option shows up in the right click menu. 当用户右键单击任何电子邮件时,我有一个Outlook加载项代码,该加载项选项会显示在右键单击菜单中。 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. 对于Outlook 2007和Outlook 2010会发生这种情况,但是当我在Outlook 2013中安装插件时,该选项不会显示在右键单击菜单中。

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 ? 如何使外接程序选项在Outlook 2013中可见? Any suggestions ? 有什么建议么 ?

Command bars have been deprecated - you have to use IRibbonExtensibility to customize context menus for Outlook 2013+: 不建议使用命令栏-您必须使用IRibbonExtensibility自定义Outlook 2013+的上下文菜单:

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

Eric is right on the depreciation of the command bar since Office 2013. And it has been a good thing I think. 自Office 2013以来, 埃里克(Eric )就对命令栏的贬值是正确的。我认为这是一件好事。

I would recommend to use: 我建议使用:

  1. the Ribbon designer available with VSTO using Visual Studio. 使用Visual Studio的VSTO提供的Ribbon设计器。 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. 附加事件的工作方式与Windows窗体或WPF设计器中的习惯相同。

    Useful reading on MSDN here . 在MSDN上有用的阅读这里

  2. the Fluent UI and IRibbonExtensibility to bind to context menus, etc. Fluent UI和IRibbonExtensibility绑定到上下文菜单等。

    Useful reading on MSDN here and here . 关于MSDN的有用的阅读在这里这里

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. 您可以在Outlook 2007中使用一种旧方法(CommandBars)。但是从Outlook 2010开始,Fluent UI用于自定义Outlook中的上下文菜单。 You can read more about that in the following articles: 您可以在以下文章中阅读有关此内容的更多信息:

The Fluent UI (aka Ribbon UI) is described in the following articles: 以下文章描述了Fluent UI(又称Ribbon UI):

The Ribbon designer doesn't provide anything for context menus. 功能区设计器不提供任何上下文菜单。 You will need to use a ribbon XML markup for customizing context menus. 您将需要使用功能区XML标记来自定义上下文菜单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM