如何检测是否在 Outlook 2007 或 2010 中打开了 HTML 电子邮件?

Jon*_*tre 3 html html-email outlook-2007 outlook-2010

我目前正在尝试为我工作的公司撰写时事通讯。新闻通讯在所有主要互联网浏览器(IE 5.55 到 9、Chrome、Firefox、Opera)中都能正确显示,但是当有人在 Outlook 2007 或 2010 中打开它时,所有字体看起来都“炸了”。

我知道这个问题是因为 Outlook 像 Word 一样呈现 HTML 的方式,如果我手动“缩小”字体,它们在 Outlook 中看起来不错,但在任何其他电子邮件软件中都没有。

我的问题是这个。有没有办法检测是否正在 Outlook 甚至 Word 中打开电子邮件?鉴于 Outlook 不允许使用 JavaScript,此解决方案必须是纯 HTML。我的计划是检测电子邮件浏览器并动态更改字体(一种 if-else)。

感谢您的帮助!

Mat*_*lin 6

有条件的评论

可以使用条件注释来实现这一点。

<!--[if mso ]>      ...<![endif]-->    <!-- Outlook -->
<!--[if gte mso 12]>...<![endif]-->    <!-- Outlook 2007+ -->
<!--[if gte mso 14]>...<![endif]-->    <!-- Outlook 2010+ -->
<!--[if gte mso 15]>...<![endif]-->    <!-- Outlook 2013+ -->
<!--[if !mso ]>     ...<![endif]-->    <!-- Not Outlook -->
Run Code Online (Sandbox Code Playgroud)

由于 Outlook 支持style头部或正文中的标签,因此可以执行以下操作:

<!--[if gte mso 12]>
<style type="text/css">
.myClass {
    /* Special styling for Outlook 2007 and later */
}
</style>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

在 Outlook 2007/2010/2013 中使用条件注释在 Litmus 上测试良好。