Sep 20, 2010

Dynamic Inline Styling

Microsoft Outlook 2007 and also the version 2010 are very bad at rendering HTML. They use Word to render HTML! There has been holly war on this issue but we have to deal with it for years to come.

Let me explain the problem briefly, emails in general requires inline styling as webmails like Gmail and Hotmail strips all stylesheet files. Outlook is the worst and needs table, so generally speaking if you want the email to appear correctly, the email must be done in tables with inline styling. When many websites are running on the same code, it is difficult to use the same email template for all sites. The quick solution would be to create a template for each one. But let me suggest another idea.

What I did was that the email template was made the same with classes, just as you would do for a site:
<table border="0" cellspacing="0" class="tableContent">{some content}</table>

Afterwards, the css file is not actually a css file, but a php file that contains an array, it will all make sense afterwards:
$style_email['class="tableContent"'] = 'style="font-family:tahoma, arial; font-size:11px; color:#222222;"';

All the styles are defined like that, then just do a str_replace, the $email_order contains the email template:
global $style_email;

//include default css
include (DEFAULT_CSS);

//overwrite some css if needed
if (file_exists (SITE_CSS)) {
    include (SITE_CSS);
}

foreach($style_email as $key=>$value) {
    $inline_email_template = str_replace($key, $value, $email_template);
}

It is pretty neat and works really well, you can continue further more, by including the default css first and then including the particular css and strip div and span tags. There you are, the email can be coded with class and it will be shown on all browsers.

2 comments:

  1. Laws in this a part of} the world prohibit paid on-line gambling. Yet, residents nonetheless discover a method to get to the paid slots on the Internet and make significant 정카지노 income. Japan - this country additionally joins the ones talked about above in terms of|when it comes to|by method of} slot recognition.

    ReplyDelete
  2. ● If you expertise too many successive losses, doubling your bet may attain the desk limit. That’s certainly a huge bummer since you won’t get a chance to double your wager once as} more. If paying a 5 % fee on the Banker irks you, it may be greatest to strive your luck on the Player hand, which comes with a touch worse 1xbet home advantage of 1.24 %. After all, the core goal of gambling is to complement yourself, not lose your cash to the house. This happens if the Banker’s count is less than three or as stipulated by the most favorable odds. The values of the 2 playing cards are added to determine out} the worth of each hand.

    ReplyDelete