【问题标题】:how to add a new option to context menu of hyperlink in an email for Outlook 2010?如何在 Outlook 2010 的电子邮件中为超链接的上下文菜单添加新选项?
【发布时间】:2014-02-22 19:32:42
【问题描述】:

我确实在该超链接上下文菜单中添加了一个新菜单项。现在我需要找到我右键单击的超链接。

我得到的是来自 Office.IRibbonControl.Context 的整个电子邮件项目,它是一个带有一个选择的 Outlook.Explorer。选择结果是一个 OutlookItem。

它确实有一个电子邮件正文。但我里面可能有多个超链接。它必须是一种获取超链接的方法,因为其他菜单项也可以:打开、选择、复制超链接。

有什么想法吗?

【问题讨论】:

    标签: c#-4.0 outlook


    【解决方案1】:

    星期天过去了,抱歉。但是我遇到了同样的问题并找到了以下解决方案:

        public void OnCustomHyperlinkMenuClick(IRibbonControl control)
        {
            Explorer explorer = control.Context as Explorer;
            if (explorer != null)
            {
                Document document = explorer.ActiveInlineResponseWordEditor;
                if (document != null && document.Windows != null && document.Windows.Count > 0)
                {
                    Microsoft.Office.Interop.Word.Selection selection = document.Windows[1].Selection;
                    if (selection != null && selection.Hyperlinks != null && selection.Hyperlinks.Count > 0)
                    {
                        Hyperlink hyperlink = selection.Hyperlinks[1];
                        string hyperlinkUrl = hyperlink.Address;
                        DoSomethingWithUrl(hyperlinkUrl);
                    }
                }
            }
        }
    

    您需要在您的 Outlook 添加项目中添加对单词互操作程序集“Microsoft.Office.Interop.Word.dll”的引用。

    【讨论】:

      猜你喜欢
      • 2016-11-21
      • 1970-01-01
      • 2013-07-13
      • 1970-01-01
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-22
      相关资源
      最近更新 更多