A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Rule Category Conditions Query



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 4th 10, 07:40 PM posted to microsoft.public.outlook.program_vba
Jabba1963
external usenet poster
 
Posts: 1
Default Rule Category Conditions Query

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

Ads
  #2  
Old March 5th 10, 03:21 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Rule Category Conditions Query

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

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Jabba1963" wrote in message
...
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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2003/2007 Rule and Conditions for InBox VBA customization GreyCoderII Add-ins for Outlook 3 March 23rd 09 09:35 PM
Send response based on category rule; auto remove category? tish Outlook and VBA 3 October 31st 08 08:04 PM
Custom Rule that Opens Incoming Message Meeting Conditions Chris Dunbar Outlook and VBA 2 October 15th 08 02:55 PM
Setting reminders by rule or category in Outlook 2003? hmjarvis Outlook - Calandaring 0 June 21st 06 07:18 AM
Message rule query mikey Outlook Express 6 April 11th 06 08:12 PM


All times are GMT +1. The time now is 09:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.