<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yet another blog about PHP, HTML and CSS &#187; HTML e-mail</title>
	<atom:link href="http://blog.pepa.info/php-html-css/category/html-e-mail/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pepa.info</link>
	<description>Petr 'PePa' Pavel</description>
	<lastBuildDate>Thu, 19 Aug 2010 18:17:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Absolute positioning in HTML e-mails for Outlook 2007</title>
		<link>http://blog.pepa.info/php-html-css/html-e-mail/absolute-positioning-outlook-2007/</link>
		<comments>http://blog.pepa.info/php-html-css/html-e-mail/absolute-positioning-outlook-2007/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 19:20:54 +0000</pubDate>
		<dc:creator>Petr 'PePa' Pavel</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML e-mail]]></category>

		<guid isPermaLink="false">http://blog.pepa.info/?p=21</guid>
		<description><![CDATA[I couldn&#8217;t possibly explain my frustration from Microsoft switching Outlook&#8217;s rendering engine to Word so I better not even try. Instead, I&#8217;m going to tell you how to make Outlook/Word position elements absolutely. The idea originally came from doublethink (written in Czech) who made a text field in Word, saved it as HTML and then [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t possibly explain my frustration from Microsoft switching Outlook&#8217;s rendering engine to Word so I better not even try. Instead, I&#8217;m going to tell you how to make Outlook/Word position elements absolutely.</p>
<p>The idea originally came from <a title="Outlook 2007: HTML templates" href="http://doublethink.cleverweb.cz/1-outlook-2007-html-sablony" target="_blank">doublethink</a> (written in Czech) who made a text field in Word, saved it as HTML and then dug through the mess to extract the essence. I just went a step further and did the same for images as well.<br />
<span id="more-21"></span><br />
Start by adding this to tag HTML:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;html xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;&gt;</div>
</li>
</ol>
</div>
<h3>Images</h3>
<p>We&#8217;re lucky Word knows how to insert pictures and &#8220;wrap&#8221; the text behind/above the picture.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;!&#8211;[if gte vml 1]&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;v:shape id=&quot;headerShapeImg&quot; type=&quot;#_x0000_t75&quot;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;style=&quot;position: absolute; height: 106px; width: 769px; z-index: -1;&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;v:imagedata src=&quot;/pix/header.png&quot; alt=&quot;this is my header&quot;/&gt;
</div>
</li>
<li class="li2">
<div class="de2">&lt;/v:shape&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;![endif]&#8211;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;![if !vml]&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;img v:shapes=&quot;headerShapeImg&quot; src=&quot;/pix/header.png&quot; id=&quot;headerImg&quot; alt=&quot;this is my header&quot;&gt;
</div>
</li>
<li class="li2">
<div class="de2">&lt;![endif]&gt;</div>
</li>
</ol>
</div>
<p>Place the whole thing directly into BODY, both parts where the image is supposed to be. Please note that the IMG tag will be used only for engines other than Word and MSIE.</p>
<p>ID &#8220;headerImg&#8221; is there to provide reference for further formatting &#8211; although don&#8217;t expect it to work in Word/Outlook. The only universal method is to use inline CSS via STYLE. Also like it or not, you&#8217;ll have to duplicate your formatting definition &#8211; define it both for V:SHAPE and for IMG (or DIV, see below).</p>
<h3>Others</h3>
<p>Other stuff must be wrapped in a div like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;!&#8211;[if gte vml 1]&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;v:shape id=&quot;tableShape&quot; type=&quot;#_x0000_t202&quot; filled=&quot;f&quot; stroked=&quot;f&quot;
</div>
</li>
<li class="li1">
<div class="de1">style=&quot;position: absolute; margin-left: 280px; margin-top: 76px; z-index: 1; width: 470px;&quot;&gt;&lt;/v:shape&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;![endif]&#8211;&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;div v:shape=&quot;tableShape&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&#8230;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;</div>
</li>
</ol>
</div>
<p>I&#8217;m sure you have already guessed the meaning of attributes filled (background color) and stroked (frame border). Remember, this is Word so we&#8217;re talking about a &#8220;text frame&#8221;.</p>
<p>That&#8217;s also a reason why you have to use margin-left and margin-top instead of top and left, or even margin: top right bottom left. And don&#8217;t forget to add width to every absolutely positioned element &#8211; in numbers, &#8220;auto&#8221; doesn&#8217;t count.</p>
<h3>Duplicate formatting</h3>
<p>Sweet, huh? Here&#8217;s what I used to make my life easier. We&#8217;re PHP programmers, remember?</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1"><span class="re0">$tableStyle</span> = &lt;&lt;&lt;HEREDOC</span></div>
</li>
<li class="li1">
<div class="de1">position: absolute;</div>
</li>
<li class="li1">
<div class="de1">margin-left: 280px;</div>
</li>
<li class="li2">
<div class="de2">margin-top: 76px;</div>
</li>
<li class="li1">
<div class="de1">z-index: <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">width: 470px;</div>
</li>
<li class="li1">
<div class="de1">HEREDOC;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
<li class="li2">
<div class="de2">&lt;v:shape id=<span class="st0">&quot;tableShape&quot;</span> &#8230;</div>
</li>
<li class="li1">
<div class="de1">Â style=<span class="st0">&quot;&lt;?php echo $tableStyle; ?&gt;&quot;</span>&gt;&lt;/v:shape&gt;</div>
</li>
<li class="li1">
<div class="de1">&#8230;</div>
</li>
<li class="li1">
<div class="de1">&lt;div v:shape=<span class="st0">&quot;tableShape&quot;</span></div>
</li>
<li class="li1">
<div class="de1">Â style=<span class="st0">&quot;&lt;?php echo $tableStyle; ?&gt;&quot;</span>&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&#8230;</div>
</li>
</ol>
</div>
<p>The output will still contain duplicated formatting but at least, you have a single place for changes.</p>
<h3>How to debug</h3>
<p>The first method that comes to your mind is probably to run your mailing script and then wait for the e-mail to arrive to your Outlook. Since we&#8217;re in fact debugging for Word I preferred to open it directly in Word. I wrote my script to display the HTML &#8220;e-mail&#8221; as a web page instead of sending it and then I opened the url in Word via CTRL+O. You are allowed to paste a url and Word downloads it.</p>
<p>For command line lovers (like me):</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&quot;C:\Program Files\Microsoft Office\Office12\WINWORD.EXE&quot; http://server.com/path/page.php</div>
</li>
</ol>
</div>
<p>You&#8217;ll have to be careful about local cache so append fictitious parameters in order to force reload:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">http://server.com/path/page.php&amp;amp;whatever=changing_value</div>
</li>
</ol>
</div>
<p>During early stages debug locally with dummy data, of course. No need for the HTML page to be generated by a script using real data. Note though, that when you open a file in Word you cannot write to it using another editor. And when you save from Word you get  back all the marvellous garble that you have worked so hard to erase. Enjoy!</p>
<h3>Some formatting must be applied to a child element</h3>
<p>Did I mention that text-align: right works only when it&#8217;s NOT in the DIV we position but in its child? The same is true for font-family, font-weight and font-size:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;div v:shape=<span class="st0">&quot;myShape&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;div style=<span class="st0">&quot;text-align: right; font-family: sans-serif;&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">hello world</div>
</li>
<li class="li1">
<div class="de1">&lt;/div&gt;</div>
</li>
<li class="li2">
<div class="de2">&lt;/div&gt;</div>
</li>
</ol>
</div>
<p>will work while if you join the two DIVs together, it will not.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pepa.info/php-html-css/html-e-mail/absolute-positioning-outlook-2007/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
