Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
655 views
in Technique[技术] by (71.8m points)

outlook - formatting email body using 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

Image: Email Screenshot

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...