gpt4 book ai didi

c# - 访问正在 Outlook 阅读 Pane 中编辑的文档

转载 作者:行者123 更新时间:2023-11-30 13:02:00 24 4
gpt4 key购买 nike

我编写了一个简单的 VSTO 插件,当用户单击功能区栏按钮时,它会在电子邮件中插入一个超链接。这是一个代码示例:

    private void button1_Click(object sender, RibbonControlEventArgs e)
{
var context = e.Control.Context as Inspector;

if (context != null)
{
if (context.IsWordMail())
{
var doc = context.WordEditor as Document;
if (doc != null)
{
var sel = doc.Windows[1].Selection;
doc.Hyperlinks.Add(sel.Range, "http://www.google.com", "", "", "Google", "");
}
}
}
else if (e.Control.Context is Explorer)
{
Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();

if (explorer.Selection.Count == 1)
{
Microsoft.Office.Interop.Outlook.Selection itemSelection = explorer.Selection;
var item = itemSelection[1] as MailItem;

// get the instance of WordEditor in a reading pane?

}
}
}

当在单独的窗口中编辑电子邮件时,这很有效(e.Control.Context is Inspector)。

如果正在回复/转发消息并且阅读 Pane 已打开,则编辑器将内联显示在阅读 Pane 中(e.Control.Context is Explorer)。

在这种情况下,我不知道如何获取 Document 的实例。我可以访问在资源管理器中选择的项目,但我不知道如何访问显示在阅读 Pane 中的文档编辑器。

如果我将编辑器“弹出”到一个单独的窗口,它工作正常(上下文更改为 Inspector)。

有没有办法访问直接在阅读 Pane 中编辑的电子邮件文档?


Dmitry 的大力帮助下谁向我指出了正确的方向我发现 Explorer 类中有一个属性:Explorer.ActiveInlineResponseWordEditor,它为您提供内联显示的编辑器。

最佳答案

  1. 您可以调用 MailItem.GetInspector,然后调用 Inspector.WordEditor。这在较新版本的 Outlook 中应该可以正常工作。 Outlook 2016 还公开了 Explorer.ActiveInlineResponseWordEditor 属性。

  2. 您可以使用 SafeExplorer Redemption 中的对象(我是它的作者)- 它应该适用于所有版本的 Outlook,并且它公开了 SafeExplorer.ReadingPane 属性(ReadingPane 对象)。

关于c# - 访问正在 Outlook 阅读 Pane 中编辑的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16881427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com