script to clear out categories on incoming emails

G

gbonawitz

I use categories to sort emails (and rules to automatically assign
categories to incoming email), and have custom search folders to
display emails from each category. For those emails that I haven't
assigned a category yet, I have a search folder that looks for emails
with no category. This works great...unless other people have rules on
outgoing email to assign categories that I don't have.

Unfortunately, I can't create a search folder who's filter is "Category
<> my_category 1 OR my_category2", etc. So, I want to create a
script-driven rule that first removes all categories on incoming email,
then I can let my other rules run to assign my categories.

I am an absolute Outlook macro beginner, but cobbled together the
following code from samples in this group and other websites...
(this is just test code to see if I can manipulate the categories
correctly)

Sub test2(Item As Outlook.MailItem)
MsgBox "Mail message arrived: " & Item.Subject
Item.Categories = "Greg"
Item.Save

End Sub

I have a rule to run this script first on every incoming email.
However, it doesn't appear to work - I don't even get the msgBox (a
test line), let along the test category assignment. Can someone help?

Thanks
 
M

Michael Bauer

Am 27 Jul 2006 13:37:22 -0700 schrieb (e-mail address removed):

Did you write that code into the module "ThisOutlookSession"? Additionally,
the security setting must be medium at least to allow scripts, then please
restart Outlook.
 
G

gbonawitz

Hi Michael-

1) OK, I hadn't previously been editing "ThisOutlookSession". I copied
my code to there.

2) I changed the zone to Medium. Now it's working.

Thanks for the tip!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top