簡體   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