user30772
user30772

Reputation: 166

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

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

Upvotes: 10

Views: 7568

Answers (2)

Mogsdad
Mogsdad

Reputation: 45750

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?.

Upvotes: 4

Alexander Obenauer
Alexander Obenauer

Reputation: 127

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).

Upvotes: 3

Related Questions