Rule Category Conditions Query

  • Thread starter Thread starter Jabba1963
  • Start date Start date
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
 
oCategoryCondition.Categories takes/returns a string array, it's not a
collection.
 
Back
Top