Html VBA中电子邮件正文的字体样式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21090295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Font style for e-mail body in VBA
提问by DNac
I have the following code written in VBA:
我有以下用 VBA 编写的代码:
Dim StrBody As String
StrBody = "Text Line 1" & "<br>" & _
"Text Line 2" & _
How do I change the font to get a particular style (e.g. Arial), size, and color?
如何更改字体以获得特定样式(例如 Arial)、大小和颜色?
The text is used as the body of an e-mail. That's why some better looking style needs to be used. The default font is "Times New Roman".
该文本用作电子邮件的正文。这就是为什么需要使用一些更好看的样式。默认字体为“Times New Roman”。
回答by Jean-Fran?ois Corbett
I imagine you would have to use the font
tag and its various attributes:
我想您将不得不使用font
标签及其各种属性:
StrBody = "<font size=""10"" face=""Arial"" color=""red"">" & _
"Text Line 1" & "<br>" & _
"Text Line 2" & _
"</font>"
Make sure the "
quotes used to surround HTML attribute values don't get interpreted as the end of the VBA string: escape them by writing ""
instead, as in the example above.
确保"
用于将 HTML 属性值括起来的引号不会被解释为 VBA 字符串的结尾:通过写入""
来转义它们,如上例所示。
color
can also be specified as hexadecimal RGB codes. So color="red"
could be replaced by the more general color="#FF0000"
.
color
也可以指定为十六进制 RGB 代码。所以color="red"
可以换成更通用的color="#FF0000"
。