2011-07-01 134 views
1

我面臨的情況是,我可以使用Word Editor修改打開的收件箱(活動資源管理器)的內容。使用Word編輯器修改Outlook 2007中的收件箱電子郵件

我知道使用文字編輯器撰寫窗口,但有沒有一種方法來訪問電子郵件的身體徹底的文字編輯器。

編寫窗口中使用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); 

} 

} 

} 

回答

2

可能在這裏回答已經太遲了,但它可以幫助其他開發者解決與我相同的問題。

如何將Word文檔文本添加到Outlook撰寫電子郵件?

讓我們假設你有一個Word文檔在你的目錄中的某個地方,並且想用你的文檔文本填寫你的撰寫郵件。

在這裏,我只是修改你的Click事件

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);  
} 
相關問題