我需要格式化从 Outlook 中的 Excel 获取的特定字符串值。
一旦 Excel 提供了该值,宏就会将该值附加到电子邮件中。
我尝试测试并将值设置为粗体,但消息的所有内容都变成粗体。如何设置值的格式,以便我可以根据自己的喜好使用字体类型、大小和颜色?
obj.HTMLBody = "<b>" & StrAgnt & vbCrLf & obj.HTMLBody
See 使用 Outlook HTMLBody
Option Explicit
Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
Dim StrAgnt As String
StrAgnt = "<HTML><H2>The body HTML.</H2><BODY>Type the message text here. </BODY></HTML>" & vbCrLf & vbCrLf & _
"<P><FONT FACE=""Comic Sans MS"" size=""6"" color=""red""><B>TEST.</B></FONTt></P>" & vbCrLf & vbCrLf & _
"<P><FONT FACE=""Times New Roman"" size=""4"" color=""blue""><i>TEST</i></FONT></P>" & vbCrLf & vbCrLf & _
"<P><FONT FACE=""Arial"" size=""3"" color=""green"">TEST</FONT></P>" & vbCrLf & vbCrLf
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = StrAgnt
.Display
End With
End Sub
MSDN HTMLBody 属性
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)