Making a newsletter generator for the win32 cmd shell.. That’s right!
I spent the better parts of yesterday re-constructing a php/xml website into "local HTML" that Microsoft Outlook could use, exchanging most of the background images, cropping and positioning with carefully crafted HTML tables anno 1998. Apparently MS Outlook can’t be arsed to follow ANY CSS OR HTML standards AT ALL, and on top of that they add their own imaginations.
Let me demonstrate with this little snippet:
6 lines of code, omitting the DOCTYPE. Outlook turns that into this: outlook-2007-email.txt. Yes, you are right. That is 295 lines of code.
So it took some trial and error to figure out what worked. When I finally had the layout done I baked the working HTML into a CMD file that coughs up 3 temporary files using ECHO: header, footer and loopfile. Essentially this is the HTML file I created split in three parts. The user is prompted for how many front-page stories he wants in the newsletter mail, then the script crafts an HTM file from the header, the wanted number of stories, plus the footer, before deleting the temp files and exiting.
Then I write step-by-step instructions on how to use the output in Word’s Mail Merge utility, batch-sending spam in all its HTML glory. The worst thing is, it actually looks OK in non-Microsoft mailboxes as well (I tested gmail and Thunderbird). But come to think of it, the last two days’ work is the result of someone not wanting to send out plain text newsletters, and insisting on mimicking a website that is not easily created in an Outlook-friendly manner. *shudder* Only a Twilight movie would be worse.