We wanted to send out a "Seasons Greetings" mail to our customers. I asked why we couldn't just use Office's mail merge feature, and it turned out that we wanted a custom "from" for each recipient, so that every customer would get the email from his sales rep. This requirement was later dropped, at which point I realized that Outlook doesn't mail merge for email. You can only mail merge if you're going to print, fold, and post your snail mail. Ugh!
Of course we wanted to send HTML mail with colors and pictures, and of course I was offended and wanted to secretly make it multipart/alternative. This gave me a reason to learn how to use some new PEP modules, mostly Email::MIME and Email::MIME::Creator. I managed to write a simple mail merger for multipart mail in just a few lines of Perl. It's not fantastic, but it's reusable for ... well, next Christmas, if nothing else.
I make a directory with just a few files:
addrs - a tab-delim list of salutations and email addresses
part.plain - TT2 template of the plaintext part
part.html - TT2 template of the html part
The directory should really store the sender and subject in a file; it'd be a simple use of IO::All to do so; I'll get around to it next year.
http://rjbs.manxome.org/hacks/perl/mailmerge
Re:mail merge
rjbs on 2004-12-23T12:59:59
Why didn't you anticipate that I was doing this and ring me at the office?!
Oh well. MS Help wasn't forthcoming about this on searches for "email merge," and I didn't think to try in Word. I forget that some people (ugh) use Word to edit email.
Hey, it got me to learn more Email:: stuff, so that's good, right? Right??
Re:how many would that be
rjbs on 2004-12-23T23:54:38
I sent a few hundred emails. It was certainly faster to do what I did (learn the requisite Email:: modules and write a script) than it would have been to edit each one by hand for the right salutation.
It would have been faster to use Office. Of course, that wouldn't have worked with the initial (but later dropped) requirement.
So, it wasn't a horrible idea, and I got to learn something new. Yay!