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

scb*_*998 2 vba string-formatting outlook-vba outlook-2010

我有以下代码部分,它是我正在开发的自动回复系统的一部分.据我所知,它应该使用换行符格式化电子邮件的正文,但是,如附带的屏幕截图所示,它不会.有人会指出我出错的地方吗?

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
Run Code Online (Sandbox Code Playgroud)

图片: 电邮截图

L42*_*L42 5

如果您使用,.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
Run Code Online (Sandbox Code Playgroud)

希望这对你有用.
您也reportbody应该使用相同的格式HTML Tags.