Frage

I want to include style sheet in the email body while sending an email with SMTP. Is it possible, as I don't want to give inline style to each and every html tag.

If i include class="sampleClass" in any HTML tag then it is not appearing in the email view source, why?

How can I include internal style sheet in body, while sending email?

War es hilfreich?

Lösung

As this page says: http://css-tricks.com/using-css-in-html-emails-the-real-story/ you cannot link to an external style sheet, but you can add inline styles. so it looks like adding inline styles is a viable option.

Also, you cannot add styles to the head section, since some mail clients do not support it, again refer to http://css-tricks.com/using-css-in-html-emails-the-real-story/, so just concentrate on adding inline styles.

Andere Tipps

You can use style tag and define there inside mail itself. As follow

 <style type="text/css">
 </style>

and use those styles in you message.

similar question

  1. How to send web page in email body with css
  2. CSS on Email

Although it is possible as such, having a consistent and working template in major webmails and mail client is already very tricky, and using styles, even in an inline <style> tag make it even more tricky. Actually, to design a mail template, you should forget everything you know about best practices on the web, and consider this a completely different medium that appears to understand some HTML and CSS.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top