繁体   English   中英

如何检测 HTML email 是否在 Outlook 2007 或 2010 中打开?

[英]How can I detect if an HTML email is being opened in Outlook 2007 or 2010?

我目前正在尝试为我工作的公司撰写时事通讯。 The newsletter appears correctly in all major internet browsers (IE 5.55 to 9, Chrome, Firefox, Opera), but when anyone opens it in Outlook 2007 or 2010, all the fonts look "blown up".

I am aware this issue is because of Outlook's way of rendering HTML like Word would, and if I manually "shrink" the fonts, they look good in Outlook but not in any other email software.

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

谢谢您的帮助!

有条件的评论

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

<!--[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 -->

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

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

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

使用以前版本的 Outlook(2003 年及以下版本),您可以使用 IE CSS hack,但现在不能。

与您的问题相关,您无法检测到它是否正在与 Outlook 一起查看,即使您这样做了,正如我所说,您真的不能有条件 styles :(

我的建议是用像素来设置文本的样式(我敢打赌你用的是点,对吧?)。 我这么说是因为我已经完成了几封 html 电子邮件,发往各种 email 客户端,并且字体大小在不同 Z0C83F57C786A0B4A39EFAB23 客户端之间是相同的(或多或少,但至少差别不大)

唯一无法设置样式的是缩小/减小行高。 Outlook 不允许这样做。 样式也应设置为内联。

过去常用的做法是在 html 中添加图像。 您可以向他们添加一个参数来跟踪电子邮件。

<img src="image.php?email=123">

当然,如今几乎每个 email 客户端都会阻止进一步的请求。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM