使用 VBA 格式化电子邮件正文 [英] formatting email body using VBA

查看:132
本文介绍了使用 VBA 格式化电子邮件正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have the following section of code, which is part of an automatic reply system im developing. As i understand it, it should format the body of the email with line breaks, but, as the attached screenshot shows, it doesnt. Can somebody point oput where im going wrong?

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 Tags.
试试这个:

If you use .HTMLBody then you should write it using HTML Tags.
Try this:

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 标签 采用相同的格式.

Hope this works for you.
Also your reportbody should be in the same format using HTML Tags.

这篇关于使用 VBA 格式化电子邮件正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆