![]() |
#1
|
|||
|
|||
![]()
Hi all,
I created a macro to add a filtering rule in Outlook 2007. Each day, this rule must be updated. Do you know how I can specifiy in the beginning of my macro to look for the existing rule, if found, delete it and then create the updated rule. Like a daily update of the rule if you prefer... Thanks Code:
Sub CreateRule() Dim colRules As Outlook.Rules Dim oRule As Outlook.Rule Dim colRuleActions As Outlook.RuleActions Dim oMoveRuleAction As Outlook.MoveOrCopyRuleAction Dim oFromCondition As Outlook.ToOrFromRuleCondition Dim oExceptSubject As Outlook.TextRuleCondition Dim oInbox As Outlook.Folder Dim oMoveTarget As Outlook.Folder 'Specify target folder for rule move action Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox) 'Assume that target folder already exists Set oMoveTarget = oInbox.Folders("Test") 'Get Rules from Session.DefaultStore object Set colRules = Application.Session.DefaultStore.GetRules() 'Create the rule by adding a Receive Rule to Rules collection Set oRule = colRules.Create("Test's rule", olRuleReceive) 'Specify the action in a MoveOrCopyRuleAction object 'Action is to move the message to the target folder Set oMoveRuleAction = oRule.Actions.MoveToFolder With oMoveRuleAction .Enabled = True .Folder = oMoveTarget End With 'Specify the exception condition for the subject in a TextRuleCondition object 'Exception condition is if the subject contains "fun" or "chat" Set oConditionSubject = oRule.Conditions.Subject With oConditionSubject .Enabled = True .Text = Array("bla", "gla") End With 'Update the server and display progress dialog colRules.Save End Sub |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2010 and modify font on existing e-mail | snowens | Outlook | 1 | 04-06-2011 01:57 PM |
delete email message via blackberry and have it delete on my pop3 and my outlook | Iamthestorm | Outlook | 2 | 10-28-2010 12:21 AM |
How do I set up a custom rule in Outlook 2002 | mastermind | Outlook | 0 | 03-11-2010 11:03 PM |
Having trouble with keywords in Outlook Rule | mfarring | Outlook | 0 | 02-03-2010 08:17 AM |
![]() |
RDeBord | Outlook | 2 | 01-21-2006 07:47 AM |