Email template - target specific email client (gmail)

為{幸葍}努か 提交于 2020-05-14 09:42:23

问题


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 divs 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!