出于我的考虑,我继续进行了一些测试,以查看发送的代码发生了什么。当我们使用 Outlook 发送 HTML(作为电子邮件)时,Outlook 每次都会更改 HTML。
例如,当通过 Outlook 2013 发送以下代码时:
<table align="center" aria-hidden="true" border="0" cellpadding="0"
cellspacing="0" role="presentation" style="max-width: 600px;" widdth="100%">
<tbody>
<tr>
<td style="font-family:Trebuchet MS,Arial,sans-serif; color:#000000; font-size:11px; mso-line-height-rule:exactly; line-height:95%;">
<span style="font-family:Open Sans,Arial,sans-serif;">Text that should be displayed in Open Sans font, or Trebuchet MS as a fallback</span>
</td>
</tr>
</tbody>
</table>
它最终显示为:
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="max-width:450.0pt">
<tbody>
<tr>
<td style="padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal" style="line-height:95%"><span style="font-size:8.5pt;line-height:95%;font-family:"Open Sans";color:black">Text that should be displayed in Open Sans font, or Trebuchet MS as a fallback</span><span style="font-size:8.5pt;line-height:95%;font-family:"Arial",sans-serif;color:black">
<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
Outlook 实际上重写了大部分代码以展望 MS 认为正确的内容。现在您的问题是为什么 Outlook 2016 将文本显示为不是Times New Roman 是因为 Outlook 2013 添加了如下 CSS:
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Open Sans";}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
这可确保 Calibri 字体显示在安装了该特定字体的设备上。没有 Calibri 的 Outlook 将无法找到字体并显示默认字体 Times New Roman。
从上面的测试看来,Outlook 2016 似乎只是为了发送以 Calibri 为字体的电子邮件。我试图更改默认字体和主题,但它仍然在做同样的事情。
编辑:
您在上面提到的链接中错过了一件重要的事情,那就是!important
在网络字体堆栈之后。以下代码是您应该发送的内容:
<table align="center" aria-hidden="true" border="0" cellpadding="0"
cellspacing="0" role="presentation" style="max-width: 600px;"
width="100%">
<tbody>
<tr>
<td style="font-family:Trebuchet MS,Arial,sans-serif; color:#000000; font-size:11px; mso-line-height-rule:exactly; line-height:95%;">
<span style="font-family:Open Sans,Arial,sans-serif !important;">Text that should be displayed in Open Sans font, or Trebuchet MS as a fallback</span>
</td>
</tr>
</tbody>
</table>
添加重要标记后,Outlook 将忽略您拥有的完整字体堆栈,并且在重写代码时将字体系列中添加为 Arial,这意味着它现在应该正确显示字体。
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="600" style="width:6.25in">
<tbody>
<tr>
<td style="padding:0in 0in 0in 0in">
<p class="MsoNormal" style="line-height:95%"><span style="font-size:8.5pt;line-height:95%;font-family:"Arial",sans-serif;color:black">Text that should be displayed in Open Sans font, or Trebuchet MS as a fallback
<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
希望这就是你所追求的。