问题
I am building an email template and I am wondering if it is possible to target specific email clients (for example Gmail) to display content only when the email is viewed using those specific clients.
For example, is there a way to display this only to email viewed in gmail?
<div class="gmailOnly">This text will be displayed in Gmail only</div>
Thank you!
回答1:
It's possible to target Gmail and Inbox for the moment. You need to take advantage of the fact that the HTML is modified before it would hit the rendering engine (as in most email clients) and in these email clients the message body will start with <u></u>
tags.
This:
<!DOCTYPE html>
<html><head>
<style>
u + .body .gmail{
display:block !important;
}
</style>
</head>
<body class="body">
<div class="gmail" style="display:none;">
THIS IS GMAIL OR INBOX
</div>
</html>
will get converted to this:
<u></u>
<div class="m_-4764228206553811341body">
<div class="m_-4764228206553811341gmail" style="display:none">
THIS IS GMAIL OR INBOX
</div>
<div class="yj6qo"></div>
<div class="adL"></div>
</div>
The <u>
tags are specific to Inbox and Gmail clients. The div
s from the original template therefore will only show in those these clients.
回答2:
No, unfortunately there isn't anyway of targeting gmail clients only, like you can do with <!--[if gte mso 9]>
for Microsoft.
来源:https://stackoverflow.com/questions/35314052/email-template-target-specific-email-client-gmail