Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

rjbs (4671)

rjbs
  (email not shown publicly)
http://rjbs.manxome.org/
AOL IM: RicardoJBSignes (Add Buddy, Send Message)
Yahoo! ID: RicardoSignes (Add User, Send Message)

I'm a Perl coder living in Bethlehem, PA and working Philadelphia. I'm a philosopher and theologan by training, but I was shocked to learn upon my graduation that these skills don't have many associated careers. Now I write code.

Journal of rjbs (4671)

Wednesday December 22, 2004
01:47 PM

making my mime mail merger

[ #22419 ]

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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Oddly enough, you can do an email merge from Word rather than Outlook. I've done this as far back as Office 97. You can specify plain text for the email. We used to send email to our customers using a list in Excel as the email data source. This feature continues to exist in Office 2003 as far as I can tell. I haven't tested it for many years though. Look for "mail merge" under the tools menu.
    • 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??
      --
      rjbs
  • Just out of curiosity, how many costumers and how many sales rep. do you have?

    I assume the answer could be "enough to bother doing this", but I'm just curious as to how much time was saved.
    • 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!
      --
      rjbs