C# 在Outlook 2007中使用Word Editor修改收件箱电子邮件
我面临的情况是,我可以使用Word编辑器修改打开的收件箱(活动资源管理器)的内容 我知道在撰写窗口中使用word编辑器,但有没有办法通过word编辑器访问电子邮件正文 在“编写”窗口中使用Word编辑器的代码C# 在Outlook 2007中使用Word Editor修改收件箱电子邮件,c#,visual-studio-2010,outlook,vsto,outlook-addin,C#,Visual Studio 2010,Outlook,Vsto,Outlook Addin,我面临的情况是,我可以使用Word编辑器修改打开的收件箱(活动资源管理器)的内容 我知道在撰写窗口中使用word编辑器,但有没有办法通过word编辑器访问电子邮件正文 在“编写”窗口中使用Word编辑器的代码 public void Click(Office.IRibbonControl Control) { Outlook.Inspector uiInspector = Globals.ThisAddIn.Application.ActiveInspector(); object u
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);
}
}
}
也许现在回答这个问题已经太迟了,但它将帮助其他和我一样陷入同样问题的开发人员 如何将word文档文本添加到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);
}