PDA

View Full Version : Using VBA in conjunction with 'Rules' in Outlook



Scottie P
08-01-2004, 12:13 PM
Hi All.

I have been fiddling around with some ideas in Outlook but seem to be reaching a dead end. Is it possible to address a 'Rules' setting with VBA?

Here is where the question stems:
I have several Rules set up on Outlook - one of those is to move email, identified as potential Junk Mail to a special folder (I do like to double check to make sure I am not losing something other than Junk Mail).
Of course, when any email arrives I have the indication of such in the sysTray (via the little email icon). I wondered if it was possible to have the sysTray icon NOT display if Rule "Move Junk" has, in fact moved email to the 'Junk Yard' folder.

Perhaps there is even some setting (that I am unaware of) in Outlook that will do this for me...:dunno I took a walk through Slipstick.com and OutlookCode.com but couldn't find anything remotely close.

Ok, well that is where I am:
can I have a routine - based on the action of a Rule - to keep the icon from showing in the sysTray?
(and I am really more curious about this than needing it)

Scott

Additional Info:

Sorry, I am wondering (also) if this can be done in conjunction with both Outlook 2000 and Outlook 2002 [ currently using OL 2000 ].

jamescol
08-01-2004, 02:09 PM
Hey Scott,
What you want to accomplish is very complex. For anyone who doesn't care to read the rest of this thread and just wants an easy add-in instead, go to http://www.techhit.com/autoread/.

Why is this task so complex?

1. The system tray's mail notification icon is not an object you can control directly with VBA. To manipulate it you need to use Windows API functions.

2. Outlook doesn't provide a way to work with rules.

Microsoft does provide RULES.DLL which provides some limited rules functionality, but only with server-side rules. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/exchserv/html/comcpnts_93hw.asp

Using RULES.DLL and CDO, you could create a rule to monitor incoming junk mail and invoke the Windows API to suppress the mail folder icon.

If you haven't seen it, Outlook does have a built-in Junk Mail filter. Except for OL2003, I believe it appears directly under the Tools | Organize menu. In OL2003 Microsoft moved it to the Tools | Options | Preferences tab. Unfortunately, I think the mail icon will still appear with built-in Junk mail filter since the mail still arrives in your Inbox. I haven't tested that condition, though, since I turn off the mail notification completely on my computers as a time management process.

Cheers,
James

Scottie P
08-01-2004, 10:18 PM
James,

thank you for the informative response.
Today I did a bit more looking at OutlookCode.com (Sue Mosher's new roost) and did find a bit to get me started. Since your information was posted I just used select keywords [including API this time] and found the info within 2 minutes.

I will give the code that I found a run and see how it works out. [that code can be found here (http://www.outlookcode.com/d/code/clearenvicon.htm) ]Unfortunately, according to the write up, there may be a bit of a kink in the works due to the timing of mail delivery or some such; the link that carries the discussion [which Sue refers to regarding the timing issue] is no good so I will have to just try it out and see what happens.

Thanks again! Your info got me moving in a clearer direction. :vv

Scott