Reputation: 1
I'm currently facing issues with putting HTML into VBA to send an e-mail. The formatting isn't coming out the way I want and I've been playing around with it.
The first part of my question is to get the font size to show up Outlook to what the code states. If the font size is 22, the size is being displayed in Outlook as 16.5 (the first line).
If the font size is supposed to be set to 11, the size is being displayed as 8.5.
I have the following questions for the table: The font is showing up as Times New Roman size 12 instead of Calibri size 11. Also, all of the "Column" and "Top Line" are not aligned to the top.
Is the syntax wrong?
.HTMLBody = "<html><center><p style='font-family:calibri;font-size:22'>" & "***<u>TEXT AT TOP</u> ***" & "</center></p>" & "<br>" & "<br>" & _
"<p style='font-family:calibri;font-size:11'>" & "Good afternoon," & "</p>" & "<br>" & _
"<p style='font-family:calibri;font-size:11'>" & "Attached please find your ... <strong> Please be advised.....</strong>" & "</p>" & _
"<table><tr><td style='font-family:Calibri:align = top:font-size:11'>Column 1:</td><td style='font-family:Calibri'>Top Line</td></tr>" & "<br>" & _
"<tr><td style='font-family:Calibri:align = top:font-size:11'>Column 2</td><td style='font-family:Calibri:align = top:font-size:11'>Top Line Row 2 <br> More text</tr></td>" & "<br>" & _
"<tr><td></td><td style='font-family:Calibri:align = top:font-size:11'>Top Line Row 3 <br> More text </tr></td>" & "<br>" & _
"<tr><td style='font-family:Calibri:align = top:font-size:11'>Column 3</td><td style='font-family:Calibri:align = top:font-size:11'>Top Line Row 4:</tr></td></table>" & "<br>" & _
"<p style='font-family:calibri:font-size:11'>" & "Should you have any questions, or require any additional information, please do not hesitate to contact me anytime. Thank you!" & "</p>" & "<br>" & _
"<p style='font-family:calibri:font-size:11'>" & "Best regards," & "</p>" & _
"<table><tr><td style='font-family:Calibri:font-size:12'><strong>Size 12 text</strong> | text <br> text </tr></td>" & _
"<tr><td style='font-family:Calibri:font-size:12><strong>Name</strong></tr></td><table>" .Display
Thank you!
Upvotes: 0
Views: 3963
Reputation: 25351
You have tones of errors in your HTML:
<body>
.22pt
or 22px
.:
instead of semicolons ;
in many places.align=top
is not CSS property, so move it out of style
.<br>
between your cells and rows.</td>
must come after </tr>
, not before.<html>
.Here is cleaned HTML:
"<html><body><center><p style='font-family:calibri;font-size:22px;'>" & _
"***<u>TEXT AT TOP</u> ***</center></p><br><br>" & _
"<p style='font-family:calibri;font-size:11px;'>" & _
"Good afternoon,</p><br>" & _
"<p style='font-family:calibri;font-size:11px;'>" & _
"Attached please find your ... <strong> Please be advised.....</strong></p>" & _
"<table><tr><td style='font-family:Calibri;font-size:11px;' align='top'>Column 1:</td>" & _
"<td style='font-family:Calibri;'>Top Line</td></tr>" & _
"<tr><td style='font-family:Calibri;font-size:11px;' align='top'>Column 2</td>" & _
"<td style='font-family:Calibri;font-size:11px;' align='top'>Top Line Row 2 <br> More text</td></tr>" & _
"<tr><td></td><td style='font-family:Calibri;font-size:11px;' align='top'>Top Line Row 3 <br> More text </td></tr>" & _
"<tr><td style='font-family:Calibri;font-size:11px' align='top'>Column 3</td>" & _
"<td style='font-family:Calibri;font-size:11px;' align='top'>Top Line Row 4:</td></tr></table><br>" & _
"<p style='font-family:calibri;font-size:11px;'>Should you have any questions, or require any additional information, please do not hesitate to contact me anytime. Thank you!</p><br>" & _
"<p style='font-family:calibri;font-size:11px;'>Best regards,</p>" & _
"<table><tr><td style='font-family:Calibri;font-size:12px;'><strong>Size 12 text</strong> | text <br> text </td></tr>" & _
"<tr><td style='font-family:Calibri;font-size:12px;><strong>Name</strong></td></tr></table></body></html>"
Upvotes: 2