'How to keep vbNewLine when passing a string from Access to Outlook mail?

I have a string that contains vbNewLine positions.

For example :

Dim strSalesOrderRemarksas string

strSalesOrderRemarks= "Hello" & vbNewLine 
strSalesOrderRemarks= strExample & "World"

When I debug via Access I see:

Hello
World

Then I pass this string to an Outlook mail object.
I have a mail template that contains a body with text, in this text there is a string like this {strBody}.

Then, when I want to replace this part with the strExample it gets shown in the mail without the vbNewLine. So the output in the mail is: helloworld

This was the actual line of code

.HTMLBody = Replace(.HTMLBody, "{strBody}", strSalesOrderRemarks)

I looked at similar problems, most of them containing info about replacing a vbNewLine.



Solution 1:[1]

This is how it should be : Thanks to Brax

    strSalesOrderRemarks = Replace(strSalesOrderRemarks, vbNewLine, "<br>")
    '
    .HTMLBody = Replace(.HTMLBody, "{strBody}", strSalesOrderRemarks)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mathias Z