将 Word 文档的内容作为电子邮件正文发送时保留文本格式, [英] Preserve text format when sending the content of a word document as the body of an email,

查看:78
本文介绍了将 Word 文档的内容作为电子邮件正文发送时保留文本格式,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Word 文档的内容作为 Outlook 电子邮件的正文发送,但文本格式(粗体、颜色等)在插入电子邮件后会丢失.

I'm trying to send the content of a word document as the body of an outlook email, but it happens that the formats of the texts (Bold, color, etc) are lost after they are inserted into the email.

我也尝试过使用 word 文档作为 Envelop 项目,它确实保留了原始格式,但 .Display 方法在这种情况下不起作用.

I have also tried using the word document as an Envelop item, and it did preserve the original format but the .Display method does not work under such circumstances.

下面是我的代码

     bodi = wdDoc3.Content

     With wdApp.ActiveDocument

    .SaveAs ThisWorkbook.Path & "./Past email/Email generated on" & "-" & Format(Date, "dd mmmm yyyy") & ".doc"
    .Close

    End With

 Set Mail_Object = CreateObject("Outlook.Application")
 Set Mail_Single = Mail_Object.CreateItem(0)


With Mail_Single

 .Display

 End With

 signature = Mail_Single.body

 With Mail_Single
 .To = arr2(2, 1)
 .Subject = arr2(1, 1)
 .CC = arr2(3, 1)
 .Bcc = arr2(4, 1)
 .body = bodi & vbNewLine & signature

以下是我在网上找到的使用envelop方法的代码,但是.display或者.visible方法不会让outlook窗口弹出.它只是直接发送电子邮件,这不是我想要的.

and below is the code I found on the internet using the envelop method, but the .display or .visible method does not make the outlook window pop up. It just directly send out the email, which is not what I wanted.

set itm=wddoc3.mailenvelope.item
with itm
.to=""
.subject=""
.display

此处的 .display 不起作用

end with

我该如何解决这个问题,或者是否有其他方法可以保留文本格式?

How can I fix this or is there other ways to preserve the text format?

推荐答案

Body MailItem 类的属性返回或设置表示 Outlook 项目的明文正文的字符串.要保留任何格式,您需要使用 HTMLBody 或 Word 编辑器.

The Body property of the MailItem class returns or sets a string representing the clear-text body of the Outlook item. To preserve any formatting you need to use the HTMLBody or Word Editor.

Outlook 对象模型为工作项正文提供了三种主要方式:

The Outlook object model provides three main ways for working item bodies:

  1. 正文 - a表示 Outlook 项目的明文正文的字符串.
  2. HTMLBody - a表示指定项的 HTML 正文的字符串.
  3. 文字编辑器 -正在显示的消息的 Microsoft Word 文档对象模型.Inspector 类的 WordEditor 属性从 Word 对象模型返回 Document 类的一个实例,您可以使用它来设置消息正文.
  1. Body - a string representing the clear-text body of the Outlook item.
  2. HTMLBody - a string representing the HTML body of the specified item.
  3. Word editor - the Microsoft Word Document Object Model of the message being displayed. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model which you can use to set up the message body.

您可以在 第 17 章:使用项目实体.

因此,您可以轻松地使用 Word 编辑器来设置邮件正文,而不会丢失任何格式.

So, you can easily use the Word editor to set the message body without loosing any formatting.

这篇关于将 Word 文档的内容作为电子邮件正文发送时保留文本格式,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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