Rule Category Conditions Query

J

Jabba1963

Can't seem to get this to work... or get my head round the methods/properties
to get it right...

I've tried using the Object Explorer and even installed OutlookSpy but being
a relative beginner with no formal training in Object Orientated Code I'm
just getting a headache !!

Can anyone help put me on the straight & narrow... it would be much
appreciated - thanks

Dim colRules As Outlook.Rules
Dim oRule As Outlook.Rule
Dim colRuleActions As Outlook.RuleActions
Dim oFromCondition As Outlook.ToOrFromRuleCondition
Dim oCategoryCondition As Outlook.CategoryRuleCondition
Dim oInbox As Outlook.Folder
Dim oMoveTarget As Outlook.Folder

Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox)
Set oMoveTarget = oInbox.Folders(Foldername)

Set colRules = Application.Session.DefaultStore.GetRules()

Set oRule = colRules.Create(Rulename, olRuleReceive)

Set oCategoryCondition = oRule.Conditions.Category
With oCategoryCondition.Categories
.Categories.Add (CategoryName)
End With

oRule.Enabled = False

colRules.Save

All works fine if I comment out the category condition code - rule gets
setup but as soon as I throw the category condition in ie.

Set oCategoryCondition = oRule.Conditions.Category
With oCategoryCondition.Categories
.Categories.Add (CategoryName)
End With

it fails...

Any help appreciated - thx
 
K

Ken Slovak - [MVP - Outlook]

oCategoryCondition.Categories takes/returns a string array, it's not a
collection.
 

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