How to attach html file so that gmail's “view” option works

跟風遠走 提交于 2021-02-07 12:01:07

问题


I have a script that sends an email with an html attachment. When I select "view" in gmail I get text...however when I click on "download" instead of "view", then open it, it displays as it should.

I think it's gmail related because I observe the exact same behavior from IE, FireFox(win/linux), Chrome(win/linux)

I made a youtube video of here: http://www.youtube.com/watch?v=WkGyxcFQXS8

Am I doing something wrong?

Thanks


回答1:


Not all email clients support the <style> tag. Gmail is one of those; it only respects in-line styling.

If your code is producing the css & html, then you could change it to use in-line styles for the table.

If you want something more auto-magic, see How do I use Google Apps Script to change a CSS page to one with inline styles?.




回答2:


One way around this would be to have your script simply host the HTML file somewhere, and email a link to that file.

I cannot find any documentation from Google or the GMail team, but I would be surprised if they allowed HTML attachments to be opened and viewed (this would be a security risk, since they would essentially allow their email servers to host user-generated web content).



来源:https://stackoverflow.com/questions/10902613/how-to-attach-html-file-so-that-gmails-view-option-works

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