【问题标题】:VSTO Outlook: Creating a dynamic custom context menu for a mail item determined by subject lineVSTO Outlook:为由主题行确定的邮件项创建动态自定义上下文菜单
【发布时间】:2011-03-22 07:17:49
【问题描述】:

是否可以通过检查项目的内容向邮件项目自定义上下文菜单添加不同的项目?
例如,仅当主题行包含“重要”时才添加项目。

【问题讨论】:

    标签: .net vsto ms-office outlook-addin outlook-2010


    【解决方案1】:

    这似乎行得通。

    void Application_ItemContextMenuDisplay(Office.CommandBar CommandBar, Outlook.Selection Selection)
        {
            foreach (Outlook.MailItem m in Selection)
            {
                if (m.Subject.Contains("IMPORTANT"))
                {
                    DeliveryFailureButton(CommandBar, Selection);
                    break;
                }
            }
        }
    
        void DeliveryFailureButton(Office.CommandBar CommandBar, Outlook.Selection Selection)
        {
            Office.CommandBarButton btn = CommandBar.Controls.Add(
                  Office.MsoControlType.msoControlButton,
                  missing, missing, missing, true) as
                  Office.CommandBarButton;
            btn.Caption = "Move to IMPORTANT messages";
    
            btn.Click += (Office.CommandBarButton Ctrl, ref bool CancelDefault) =>
            {
                string msg = "CRM Records\r\n";
    
                foreach (Outlook.MailItem item in Selection)
                {
                    if (item is Outlook.MailItem)
                    {
                        var mitem = item as Outlook.MailItem;
                        msg += "\r\n" + MoveToImportant(mitem);
                    }
                }
    
                MessageBox.Show(msg);
    
            };
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-12
      相关资源
      最近更新 更多