使用VBA格式化电子邮件正文

使用VBA格式化电子邮件正文,vba,outlook,string-formatting,outlook-2010,Vba,Outlook,String Formatting,Outlook 2010,我有以下代码部分,这是我正在开发的自动回复系统的一部分。据我所知,它应该用换行符格式化电子邮件的正文,但是,正如所附的截图所示,它没有。有人能指出我错在哪里吗 With NewForward .Subject = "'TEST' Hazard report reciept number: HAZ" & IDnumber .To = strSender .BCC = "xxxxxxxxxxxx"

我有以下代码部分,这是我正在开发的自动回复系统的一部分。据我所知,它应该用换行符格式化电子邮件的正文,但是,正如所附的截图所示,它没有。有人能指出我错在哪里吗

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
图片:

好的,您正在设置HTMLBody属性的值不包括任何HTML格式


vbCrLf
这样的常量不会格式化HTML。改为使用HTML标记,例如用于换行符的

如果使用
.HTMLBody
,则应使用
HTML标记来编写它
试试这个:

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
Dim EBody作为字符串
EBody=“请接受此电子邮件,确认xxxx已收到您的道路缺陷通知。”&“
”_ &“xxxxx将根据优先级调查并采取行动,以确保公共安全。”&“
”_ &“欲了解更多信息,请致电4221 6111与xxxxx联系,并提供参考号:&”
”_ &IDnumber&“您的原始报告可以在下面看到:&”
“_ &报告体 与NewForward合作 .Subject=“'TEST'危险报告接收编号:HAZ”&IDnumber .To=strSender .BCC=“XXXXXXXXXX” .HTMLBody=Ebody .发送 以
希望这对你有用。

另外,您的
reportbody
应该与使用
HTML标记的格式相同

很高兴这样做:D您还可以使用
HTML标记
更改字体类型、字体颜色和字体大小。如果你想了解更多,你可以开始。它还允许您查看生成的代码的结果。