如何检测 HTML 电子邮件是否正在 Outlook 2007 或 2010 中打开?
我目前正在尝试为我工作的公司写一份时事通讯。该时事通讯在所有主要互联网浏览器(IE 5.55 至 9、Chrome、Firefox、Opera)中都能正确显示,但当有人在 Outlook 2007 或 2010 中打开它时,所有字体看起来都“放大了”。
我知道这个问题是由于 Outlook 像 Word 一样呈现 HTML 的方式,如果我手动“缩小”字体,它们在 Outlook 中看起来不错,但在任何其他电子邮件软件中则不然。
我的问题是这样的。有没有办法检测电子邮件是否在 Outlook 甚至 Word 中打开?鉴于 Outlook 不允许 JavaScript,此解决方案必须采用纯 HTML。我的计划是检测电子邮件浏览器并动态更改字体(一种 if-else)。
感谢您的帮助!
I am currently trying to write a newsletter for the company I work for. 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.
My question is this. Is there a way to detect whether or not an email is being opened in Outlook, or even Word? Given that Outlook doesn't allow JavaScript, this solution would have to be in plain HTML. My plan would be to detect the email browser and change the font dynamically (a sort of if-else).
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
条件注释
使用条件注释也许可以实现这一点。
由于 Outlook 支持 head 或 body 中的
style
标记,因此可以执行类似以下操作:Outlook 2007/2010/2013 中条件注释的使用在 Litmus 上测试良好。
Conditional Comments
It might be possible to achieve this using conditional comments.
Since Outlook supports
style
tags in the head or body, something like the following could be done:The use of conditional comments in Outlook 2007/2010/2013 tested fine on Litmus.
在以前版本的 Outlook(2003 及以下版本)中,您可以使用 IE CSS hack,但现在不能。
与你的问题相关,你无法检测它是否正在使用 Outlook 查看,即使你这样做了,正如我所说,你不能真正拥有条件样式:(
我的建议是使用像素设置文本样式(我敢打赌)你使用的是点,对吗?)我这样说是因为我已经发送了几封发送给不同电子邮件客户端的 html 电子邮件,并且字体大小是相同的(或多或少,但至少没有太大不同)。不同的电子邮件客户端
无法设置样式,Outlook 也不允许这样做。
With previous versions of Outlook (2003 and bellow) you could use the IE CSS hacks, now you can't.
And related to your question, you can't detect if it's being viewed with Outlook and even if you did, and as I said, you can't really have conditional styles :(
My suggestion is to style the text with pixels (I bet you're using points, right?). I'm saying this because I've done several html emails destined to various email clients, and the font-size is the same (more or less, but at least not very different) between different email clients.
The only thing that won't be possible to style is shrinking/reducing line-height. Outlook doesn't allow that. Also the style should to be set inline.
过去常用的做法是在html中添加图片。您可以向它们添加一个参数来跟踪电子邮件。
当然,如今几乎每个电子邮件客户端都会阻止进一步的请求。
The common pratice used in the past was to add an image in the html. You can add to them a param to keep track of the emails.
Of course these day almost every email clients block further requests.