Reputation: 493
I'm trying to send an email automatically through Excel, but the new line commands aren't working! I've 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 keeps just giving Hello Please find attached the above invoices and backup Any queries please let me know Regards
as one line!
Upvotes: 12
Views: 148139
Reputation: 23
Cheers mate. I ended up using VBA to do this:
strEmailBody = Replace(strEmailBody, vbCrLf, "<br>", 1)
and then
.HTMLBody = strEmailBody
This made the email look perfect. It was plain text email content from a SQL query
Upvotes: 0
Reputation:
Try wrapping the text in some rudimentary 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 a paragraph level. (not tested; no guarantees)
Upvotes: 5
Reputation: 334
May be you can try this instead: Use
.HTMLbody = "Hello" & "<br>" & "Please find attached the above invoices and backup" & "<br>"
instead of vbnewline
Upvotes: 21
Reputation: 203
Unless you need the email to be HTML try using .body instead of .html.
If you need the email to be html then you need to ensure the entire text is formatted with Html tags. - The easiest way to do this is to have you html code in a cell in your workbook and then reference this cell.
Upvotes: 0