Sub RunRuleMyRule()
Dim myRule As Outlook.Rules
Dim theRule As Outlook.Rule
Set myRule = Application.Session.DefaultStore.GetRules()
Set theRule = myRules.Item("rule1") 'get error here
If theRule.Enabled Then
theRule.Execute
Else
theRule.Enabled = True
theRule.Execute
End If
End Sub
When I debug it, theRule is "Nothing" and my code crashes. I am not sure what else can be done. I know the rule exists on the client and I've run the rule manually.
At least to prevent crashing (I don't know why the rule cannot be found when you say it exists), try: