Outlook
Rules Creator
Have you ever had to deal with
far too many emails, all unsorted? Is your inbox filled will all sorts of
important messages, but they are so disorganized you will never catch up? Have
you ever wished there was a quick and easy way to programmatically create Outlook
rules and folders in one fell swoop? If you now find yourself looking
for a way to run a single script that will create your rules and folders on the Exchange server—which will then continue filtering your emails everyday
as it would if you had manually added each individual rule—you have stumbled
upon the right website, my friend. Please read on.
Why did I create this script?
The reason I created these rules
is that in my current job, I have noticed my co-workers experience issues with
mail rules. The end result was always missing emails due to the wrong rule
catching them and moving them to the wrong folder. Email rules are no easy
task; they are a pseudo programming language which processes the rules
sequentially from top to bottom. Outlook does have a Rule Wizard, but it is
cumbersome when it comes to sharing the rules with someone else. The biggest
issue I found with the Wizard is that it does not create the folders needed,
and the rules are not very easy to maintain.
In what situation would this script be most useful?
The current revision of the rules
(v1.24b) is designed for use in an environment in which a pre-determined set of
keywords is already established and widely used. For example, take any new employee with no
programming experience in a company with multiple product lines specialized to
the client. The new employees usually are overwhelmed with hundreds of emails
that flow in unsorted; once rules are in place, the process is simplified.
Creating each rule manually, as I have explained, takes time to build and even
longer to perfect. Using the script I wrote, an experienced employee within the
department who knows the keywords to use in the filters can fill in the columns
on the spreadsheet and immediately create the filters and folders for the new
employee to use.
How fast are the rules created?
Using this method, creating about
60 folders and 120 rules on the Exchange server took between three and 15
minutes, depending on the computer and its location. I am not sure of the
factors at play when it comes to speed. The fastest time I measured was on a “cloud”
remote desktop computer, and the longest (15 minutes), was on a not very
powerful desktop computer. Compared to the traditional method of adding rules
and folders as you go, which in my experience takes the employee several months,
I would call this method a success.
How do the rules work?
It would be best that an
experienced employee, in the same department, who knows most of the keywords one
would need, fill in the Excel spreadsheet. The Excel file contains columns for:
the name of the rule, key word or words to seek out, domain from which emails are
sent, and words excluded from the subject line filter. In my company, we find
it necessary to sort our emails into folders based on which client the email
pertains to. Thus, we benefit from rules that filter email messages that
mention the client in the subject line, and from rules that filter emails
coming from the client’s domain (e.g., if one of the clients is XYZ Industries,
emails coming from [email protected]). If
rules must be created to filter by anything other than subject key words or
sender domain, the basic concept here can be expanded, but these are the
filters needed at my company.
There are two rules that are
created when the Outlook script is run: one is seeking words in the subject
line and the other, in the domain of the email’s sender. In other words, the
program creates a “subject” rule and a “people” rule for each line that is
entered onto the spreadsheet in Excel. Note that there must be two rules
created per line because if we combined them into a single rule, both conditions
would have to be true in order for a message to be filtered. Outlook does not
allow for rules that sort based on a match in the subject OR a match in the
sender.
A few examples are listed as they
would appear in the columns of the Excel spreadsheet.
Name of Rule
|
Words in Subject
|
Domain From
|
Exclude the following words
|
Intel
|
pentium xeon intel
|
intel.com
|
|
Mercedes Benz
|
mercedes benz
|
mbusa.com
|
Benzene
|
The above view displays the final product of the example rule mentioned
previously. The script adds an underscore plus a “p” or an “s” for people or
subject, respectively.
What if the rules do not sort as intended?
Once created, the same file can
be modified and tweaked as needed and shared again and again as new employees
are set up with email access. Each new employee is thus receiving the
up-to-date version of a department-wide or company-wide email filtering system.
If a new set of rules was to be implemented then the current rules could be
deleted and the script re-run. The folders will not be re-created, only the
rules.
Limitations and final comments
By design, the rules run in the order listed on the Excel spreadsheet. I
elected to sort them alphabetically for readability and ease of troubleshooting.
There is a known size limitation on rules in Outlook* of 32kB, but this can be
increased to 256kB in Exchange 2007 and higher. One way to minimize the size of
rules is number rather than name the rules.
When running these rules for the first time, I would recommend setting up
an alternate profile in Outlook on which you set up a “test” pop account. The
benefits of this are clear: rules are created in a separate environment and
there is no lag time associated with updating the exchange server. Once your
rules are confirmed successful, run them on your regular account. I have used
this script to create folders and filters successfully in Exchange 2007 using
Outlook 2007 and Outlook 2010 clients. I hope it serves you well.
*Per Microsoft KB886616