问题
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!
回答1:
May be you can try this instead: Use
.HTMLbody = "Hello" & "<br>" & "Please find attached the above invoices and backup" & "<br>"
instead of vbnewline
回答2:
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)
回答3:
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.
来源:https://stackoverflow.com/questions/25931716/add-new-lines-in-vba-email