Skip to content

Instantly share code, notes, and snippets.

@jangins101
Created December 14, 2015 12:02
Show Gist options
  • Save jangins101/168a1ee9cbd7c52162ab to your computer and use it in GitHub Desktop.
Save jangins101/168a1ee9cbd7c52162ab to your computer and use it in GitHub Desktop.
VBA script for Outlook to simplify running a single rule
' Rule execution
Sub RunRule(rulename As String)
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim RunRule As String
Set st = Application.Session.DefaultStore
Set myRules = st.GetRules
For Each rl In myRules
If rl.RuleType = olRuleReceive Then
If rl.Name = rulename Then
rl.Execute ShowProgress:=True
RunRule = rl.Name
Exit For
End If
End If
Next
ruleList = "Rule '" & RunRule & "' completed"
MsgBox ruleList, vbInformation, "Macro: RunRule"
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
' Set a Macro shortcut on the toolbar to a function like this
Sub RunRule_SuperAwesomeRule()
RunRule ("MySuperAwesomeRule")
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment