Add new lines to VBA email

I am trying to send an email automatically through Excel, but the new lines do not work! I tried <br/> , vbCrLf and vbNewLine

 .HTMLbody = "Hello" & vbNewLine & "Please find attached the above invoices and backup" & vbNewLine & _ "Any queries please let me know" & vbNewLine & "Regards" & vbNewLine & Signature 

It just gives Hello Please find attached the above invoices and backup Any queries please let me know Regards as one line!

+6
source share
3 answers

Perhaps you can try this instead: Use

 .HTMLbody = "Hello" & "<br>" & "Please find attached the above invoices and backup" & "<br>" 

instead of vbnewline

+11
source

Try wrapping text in some elementary HTML tags.

 .HTMLbody = "<html><body><p>Hello</p><p>Please find attached the above invoices and backup.</p>" _ & "<p>Any queries please let me know</p><p>Regards</p>" & Signature & "</body></html>" 

This assumes that the signature is already HTML formatted at the paragraph level. (not verified, no guarantees)

+4
source

If you don't need email for HTML, try using .body instead of .html.

If you need the letter to be html, you need to make sure that all text is formatted using Html tags. - The easiest way to do this is to have the html code in a cell in your book and then reference that cell.

0
source

Source: https://habr.com/ru/post/975525/


All Articles