我面临的情况是我可以使用Word Editor修改打开的收件箱(活动资源管理器)的内容。
我知道使用单词编辑器进行撰写窗口,但有没有办法通过文字编辑器访问电子邮件正文。
在撰写窗口中使用Word编辑器的代码。
public void Click(Office.IRibbonControl Control)
{
Outlook.Inspector uiInspector = Globals.ThisAddIn.Application.ActiveInspector();
object uiObject = uiInspector.CurrentItem;
if (uiObject is Outlook.MailItem && uiInspector.IsWordMail())
{
Outlook.MailItem uiItem = (Outlook.MailItem)uiObject;
Word.Document uiDoc = uiInspector.WordEditor as Word.Document;
if (uiDoc != null)
{
Word.Find uiFind = uiDoc.Range().Find;
uiFind.Text = "ASA^$^$^#^#^#^#^#";
while (uiFind.Execute())
{
var rng = uiFind.Parent as Microsoft.Office.Interop.Word.Range;
rng.Hyperlinks.Add(rng, "http://stack.com=" + rng.Text + "outlook2007");
rng.Collapse(Word.WdCollapseDirection.wdCollapseEnd);
}
}
}
答案 0 :(得分:2)
在这里回答可能为时已晚,但它会帮助遇到同样问题的其他开发人员。
如何将单词文档文本添加到Outlook撰写电子邮件中?
假设您在目录中有一个Word文档,并希望用文档文本填写撰写电子邮件。
我刚刚修改了你的点击事件
using Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Interop.Word;
public void Click(Office.IRibbonControl Control)
{
string documentPath = @"C:\\Documents";
Outlook.Inspector = OutlookApp.ActiveInspector();
Document we = inspector.WordEditor as Document;
Find wf = we.Range().Find;
wf.Application.Selection.Range.ImportFragment(documentPath);
}
答案 1 :(得分:1)