添加附件上下文菜单Outlook 2013 [英] Add attachment context menu Outlook 2013

查看:118
本文介绍了添加附件上下文菜单Outlook 2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个项目,当您用鼠标右键单击附件时,该项目将使用Outlook进行处理.

I'm working on project which uses Outlook to perform a process when you hit an attachment with mouse's right clik.

该项目在Outlook 2013之前运行良好. 我发现这篇文章解释了为什么它不再起作用了:

The project was working fine till Outlook 2013. I have found this post which explains why it does not work anymore :

在Outlook 2013中,他们已完全删除了所有内置命令栏和命令栏控件.因此,您无法在Outlook 2013中访问和使用内置的主菜单,上下文菜单和工具栏.出于相同的原因,Outlook 2013不支持AttachmentContextMenuDisplay和ContextMenuclose事件.

In Outlook 2013 they've deleted all built-in Commandbars and commandbar controls completely. For this reason you cannot access and use built-in main menus, context menus, and toolbars in Outlook 2013. The AttachmentContextMenuDisplay and ContextMenuclose events are not supported in Outlook 2013 for the same reason.

链接到该帖子

实际上,由于未触发此事件,我的程序崩溃了:

Indeed, my program crashed due to this event which is not triggered :

this.Application.AttachmentContextMenuDisplay += new Outlook.ApplicationEvents_11_AttachmentContextMenuDisplayEventHandler(Application_AttachmentContextMenuDisplay);

你们对如何使其适用于Outlook 2013有任何想法吗? 我还在寻找信息.

Do you guys have any idea about how to make it works for Outlook 2013 ? I'm still looking for information.

非常感谢!

推荐答案

解决方案在我发现的帖子中...

The solution was in the post I've found...

这是XML:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <contextMenus>
    <contextMenu idMso="ContextMenuAttachments">
      <button id="DT2MQPRContextMenuAttachments"
              label="Add to MQPR..."
              getVisible="DT2MQPRButton_GetVisible"
              onAction="OnMyButtonClick" />
    </contextMenu>
  </contextMenus>
</customUI>

以及该方法的代码:

public void OnMyButtonClick(Office.IRibbonControl control)
{
    try
    {
        object context = control.Context;
        if (context == null) return false;
        if (context is Outlook.AttachmentSelection)
        {
            Outlook.AttachmentSelection selectedAttachments = context as Outlook.AttachmentSelection;
            SelectedAttachment = attachment[1];
            OutlookCommon._fName = SelectedAttachment.FileName;
            // etc...
        }
        Marshal.ReleaseComObject(context); context = null;
        }
    catch (Exception ex)
    {
        Console.WriteLine("attachmentButton_Click  " + ex.ToString());
    }
}

如果可以帮助任何人,我们就走了;)

There we go, if it could help anyone ;)

这篇关于添加附件上下文菜单Outlook 2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆