Rule Of Thumb

We use email as part of the monitoring solutions at work. There are always a few dozen alerts issued during the working day (sometime considerably more if we have a problem…..or sometimes just a problem with the monitoring system itself :o)

To keep some sot of order on my inbox, I have created sets of rules that either move, delete or do some other action with msgs that are pushed onto me. During the working day this is all automatic and working fine.

However, out of hours presents a slight issue. we use Blackberry devices to stay in touch with our email boxes during the evenings so that we receive the email alerts from the monitoring system. A Blackberry enterprise server (BES) sits adjacent to the exchange server and watches the inbox of certain people. If a new message hits the inbox, the BES will push a copy of the email out to the blackberry mobile device. But here’s the problem, if my rules are left running active, the messages get sorted before they actually hit the inbox…….so the BES never sees them and I don’t get a copy sent to me :o(

The work around for this is pretty simple, I just deactive my rules when I leave the office at night. This does sometimes however result in my arriving to an inbox *full* with unsorted alert messages. To clear my inbox down, I have to manually run my rule sets aginst my inbox, and for the number of rules I have that’s a lot of clicking for first thing in the morning.

So I thought I would have a look at automating this task with the built in office visual basic. My first stumbling block here is pretty big. I am not a programmer/coder by any stretch of the imagination. All other office applications will allow you to get the bones of a macro down by recording your actions in the application. The vba editor then presents you with the code for the actions you just carried out, and you can flesh the code out a bit to make it more slightly more generic and vastly more useful.

Outlook does not have this recording feature :o( so, you have to start pretty much from a blank slate. The office installed help file are however incredibly useful and concicse and following them I was able lash the following together

Sub runrules()
Dim colRules As Outlook.Rules
Dim oRule As Outlook.Rule
Dim oInbox As Outlook.Folder
Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox)
Set colRules = Application.Session.DefaultStore.GetRules
For Each oRule In colRules
oRule.Execute showprogress:=True
Next
End Sub

It’s pretty short, not terribly verbose and contains no error checking, but it does do the trick (it was more verbose while I was working it out, I had msgboxes popping at various stages informing me what certain objects and their values were)

I think I’m gonna share this with my boss as he has even more inbox mail rules than I do :oO

Score those brownie points !

Tags: ,

Leave a Reply