将Word格式复制到Outlook邮件中 [英] Copy Word format into Outlook message

查看:726
本文介绍了将Word格式复制到Outlook邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Outlook自动化程序.我想使用Word文档作为邮件内容的模板.可以说我有一些包含表格,颜色,大小等的格式化文本.现在,我想将此内容复制/粘贴到Outlook消息对象中.

I have an outlook automation. I would like to use a Word document as template for the message content. Lets say i have some formatted text containing tables, colors, sizes, etc. Now I'd like to copy/paste this content into an Outlook message object.

以下是一些示例代码(无清理):

Here is some Sample Code (no cleanup):

String path = @"file.docx";
String savePath = @"file.msg";
Word.Application wordApp = new Word.Application();
Word.Document currentDoc = wordApp.Documents.Open(path);
Word.Range range = currentDoc.Range(0, m_CurrentDoc.Characters.Count);
String wordText = range.Text;

oApp = new Outlook.Application();
Outlook.NameSpace ns = oApp.GetNamespace("MAPI");
ns.Logon("MailBox");
Outlook._MailItem oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg.To = "mymail@someserver.com";
oMsg.Body = wordtext;
oMsg.SaveAs(savePath);

使用Outlook/Word 2007,但是Word文件仍可能采用2000/2003格式(.doc).
带有.net 4.0的Visual Studio 2010(由于示例代码而明显).

Using Outlook/Word 2007, however the word files still mayb in 2000/2003 format (.doc).
Visual Studio 2010 with .net 4.0 (should obvious due to the samplecode).

我习惯了互操作,而且我知道我目前只是在复制纯文本".我认为必须通过从word文档中获取rtf/html来完成...

I'm used to interop and I know that I am currently just copieing the "plain text". I think it has to be done via retreiving rtf/html from the word document...

有什么建议吗?

推荐答案

Office 2007提供了"MailEnvelope"功能,可用于我的目的.

Office 2007 offers "MailEnvelope" feature, that can be used for my purpose.

这篇关于将Word格式复制到Outlook邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆