【问题标题】:formatting email body using VBA使用 VBA 格式化电子邮件正文
【发布时间】:2014-02-10 11:17:49
【问题描述】:
我有以下代码部分,它是我正在开发的自动回复系统的一部分。据我了解,它应该用换行符格式化电子邮件的正文,但是,正如所附的屏幕截图所示,它没有。有人可以指出我哪里出错了吗?
With NewForward
.Subject = "'TEST' Hazard report reciept number: HAZ" & IDnumber
.To = strSender
.BCC = "xxxxxxxxxxxx"
.HTMLBody = "Please accept this email as confirmation that xxxx has received your road defect notification. xxxxx will investigate and action your notification according to priority and to ensure public safety. For further information, please phone xxxxx on 4221 6111 and quote reference number " & vbCrLf & IDnumber & vbCrLf & "Your original report can be seen below:" & vbCrLf & report_body
.Send
End With
图片:
【问题讨论】:
标签:
vba
outlook
string-formatting
outlook-2010
【解决方案1】:
如果你使用.HTMLBody,那么你应该使用HTML Tags来编写它。
试试这个:
Dim EBody as String
EBody = "Please accept this email as confirmation that xxxx has received your road defect notification." & "<br>" _
& "xxxxx will investigate and action your notification according to priority and to ensure public safety." & "<br>" _
& "For further information, please phone xxxxx on 4221 6111 and quote reference number:" & "<br>" _
& IDnumber & "Your original report can be seen below:" & "<br>" _
& reportbody
With NewForward
.Subject = "'TEST' Hazard report reciept number: HAZ" & IDnumber
.To = strSender
.BCC = "xxxxxxxxxxxx"
.HTMLBody = Ebody
.Send
End With
希望这对你有用。
此外,您的reportbody 的格式应与使用HTML Tags 的格式相同。
【讨论】:
-
很高兴:D 您还可以使用HTML Tags 更改字体类型、字体颜色、字体大小。如果您想了解更多,可以开始HERE。它还允许您查看生成的代码的结果。
【解决方案2】:
嗯,您将 HTMLBody 属性设置为的值不包括任何 HTML 格式...
vbCrLf 等常量不会格式化 HTML。改用 HTML 标签,例如<br> 换行。