1: Sub RunAllRules()
2: Dim st As Outlook.Store
3: Dim myRules As Outlook.Rules
4: Dim rl As Outlook.Rule
5: Dim count As Integer
6: Dim ruleList As String
7: 'On Error Resume Next
8:
9: ' get default store (where rules live)
10: Set st = Application.Session.DefaultStore
11: ' get rules
12: Set myRules = st.GetRules
13:
14: ' iterate all the rules
15: For Each rl In myRules
16: ' determine if it's an Inbox rule
17: If rl.RuleType = olRuleReceive AND rl.Enabled Then
18: ' if so, run it
19: rl.Execute ShowProgress:=True
20: count = count + 1
21: ruleList = ruleList & vbCrLf & rl.Name
22: End If
23: Next
24:
25: ' tell the user what you did
26: ' ruleList = "These rules were executed against the Inbox: " & vbCrLf & ruleList
27: ' MsgBox ruleList, vbInformation, "Macro: RunAllInboxRules"
28:
29: Set rl = Nothing
30: Set st = Nothing
31: Set myRules = Nothing
32: End Sub