我目前面临将HTML放入VBA发送电子邮件的问题。格式化并不是我想要的方式,我一直在玩它。
我的问题的第一部分是获取字体大小以显示Outlook代码所声明的内容。如果字体大小为22,则Outlook中的大小显示为16.5(第一行)。
如果字体大小应设置为11,则大小显示为8.5。
我对表格有以下问题: 字体显示为Times New Roman尺寸12而不是Calibri尺寸11.此外,所有“Column”和“Top Line”都未与顶部对齐。
语法错了吗?
.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
谢谢!
答案 0 :(得分:2)
您的HTML中存在错误:
<body>
。22pt
或22px
。:
而不是分号;
。align=top
不是CSS属性,因此请将其移出style
。<br>
。</td>
必须在</tr>
之后,而不是之前。<html>
。这是清理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>"