Skip to content

Instantly share code, notes, and snippets.

@stephenchew
Last active May 29, 2017 03:20
Show Gist options
  • Save stephenchew/a91690e472abd6332e53f27b0c4c65f0 to your computer and use it in GitHub Desktop.
Save stephenchew/a91690e472abd6332e53f27b0c4c65f0 to your computer and use it in GitHub Desktop.
Invoke all Outlook rules with the prefix `[Clean Up]`
Public Sub CleanUpAll()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim ruleList As String
Set st = Application.Session.DefaultStore
Set myRules = st.GetRules
For Each rl In myRules
If rl.RuleType = olRuleReceive Then
If InStr(rl.Name, "[Clean up]") > 0 Then
rl.Execute ShowProgress:=True
ruleList = ruleList & vbCrLf & rl.Name
End If
End If
Next
ruleList = "This rule was executed against the Inbox:" & vbCrLf & ruleList
MsgBox ruleList, vbInformation, "Clean up inbox"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment