Saturday, April 1, 2006

Writing a rule and a quick step into server programming


By David Gewirtz

Mark Brunner's doing some funky things with servers and Outlook. Here's his question:

I like your article on using the custom template for auto-replying to Outlook messages (and forwarding and what-not, but that's not my issue).
I am looking for a rule that will automatically respond to a predetermined email address (not the original sender's) every time an email arrives with specific text in the body. The custom template response will only send once to a single address, like an Out Of Office auto-reply. Not what I want.
The purpose of this is to send an alert to a Web page that contains a JavaScript, and change a security status indicator on yet another Web page as threat levels are changed and announced by various vendors and organizations.
Can you tell me how to modify your rule, find a working rule, or how to go about programming a rule of this nature? (I'm not a programmer)
Thanks for the good read.

I'm not exactly sure which article Mark's talking about, but some of our more comprehensive rule articles ran back in June. You can read them at

In any case, I'm also not absolutely sure this is a problem for Outlook, and not for your server software. But let's take a shot at parsing your request. The statement below is the key problem statement:

...automatically respond to a predetermined email address (not the original sender's) every time an email arrives with specific text in the body.

This turns out to be a classic rule construct. The second part, "every time an email arrives with specific text in the body", is the condition. You'd specify this with a "with specific words in the body" condition, as shown in Figure A.


Trigger the rule each time the specific words show up in the body. (click for larger image)

The first part of the problem statement, "automatically respond to a predetermined email address", is the action for the rule. You'd probably want to use "forward it to people or distribution list" and put in the predetermined email address, as shown in Figure B.


Once the rule is triggered, an email goes out to the address specified. (click for larger image)

Of course, you'll probably want to use a different email address!

What I didn't fully understand was whether Mark expected this rule to run only once, or each time the trigger phrase arrived in a message. As shown above, the rule will run each time the trigger phrase is seen.

Honestly, though, I'm not sure you want to use Outlook to manage a server's contents. Many server programming environments, whether PHP, Perl, Python, or even the Frontier Kernel support an email client interface. You could have the server's email client retrieve the messages and process them in a precise programmatic fashion. For example, PHP has a POP3 client library (at that allows PHP to act as an email client.