Forum Moderators: not2easy

Message Too Old, No Replies

external CSS inside email messages

can it be done at all?

         

dmmh

9:04 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



I've been trying this for quite some time now, without much success I might add

I could set up the messages so that all the style information is hard-coded, but for obvious reasons I'd like to use external CSS for this

are there any known workaround? Im using PHP's mail() function to send the messages btw :)

jetboy

9:48 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Hmmm, not an answer, but a question: What are the 'obvious reasons' that push you down the external CSS route? Here are some points against:

. If you do use an external file, you may save some bandwidth in delivery, but you'll lose it when the stylesheet is accessed on your server.

. You'll also lose all styling information if the email is viewed offline.

. Most webmail clients will strip out the <head> section of any HTML emails, so linking to the stylesheet in the usual place isn't going to work.

In my experience, embedding the stylesheet inside an HTML comment and placing the whole lot straight after the <body> tag works perfectly across all the major email apps and webmail clients. In fact the only client that has any problems with CSS in an HTML email is Lotus Notes. Even Outlook 97 can be catered for with a multipart-MIME email.

dmmh

9:52 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



ill give that a whirl

well the bandwidth isnt the most obvious reason now is it? Perhaps you forgot about the greatest power of CSS...the ability to change an entire site's look by editing 1 file? ;)
So if I change my site...I dont need to dig through my mail scripts and change them all....

thanks for yer help, ill give those suggestions a try

jetboy

10:46 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Oops. Should be:

<body>
<style>
<!--
.styles
-->
</style>
...

Can't forget those style tags.

And as for having all your styles in one place ... you have PHP at your command!

<?php

$css = file_get_contents("\path\to\mycss.css");

echo "<html><body><style><!-- ".$css." --></style></body></html>";

?>

dmmh

12:58 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



this works so good...it even overwrites Hotmail's body style properties lol :D

thanks