为什么运行所有已启用规则的代码不在 Outlook-2016 中运行?我在 Outlook 2007、2010 和 2013 上使用它没有任何问题,但它在 Outlook 2016 中不起作用。
Sub OrginalRunActiveCatInboxRules()
Dim Session As Outlook.NameSpace
Dim Report As String
Dim currentItem As Object
Dim currentRule As Outlook.Rule
Dim rules As Outlook.rules
Dim ruleList As String
Set Session = Application.Session
Set rules = Session.DefaultStore.GetRules()
For Each currentRule In rules
If currentRule.RuleType = olRuleReceive Then
'determine if it’s an Inbox rule, if so, run it
If currentRule.Enabled Then
If Left(currentRule.name, 4) = "Cat." Then
MsgBox currentRule.name
currentRule.Execute ShowProgress:=True
' Sortering niet laten zien
' ruleList = ruleList & vbCrLf & currentRule.Name
End If
End If
End If
Next
' tell the user what you did
' ruleList = "These rules were executed against the Inbox: " & vbCrLf & ruleList
' MsgBox ruleList, vbInformation, "Macro: RunAllActiveInboxRules"
Set rules = Nothing
Set currentRule = Nothing
End Sub
代码运行到下一个,但在那里给出错误。第一条规则是否启用并不重要,以 Cat 开头。或不。它只是不会转到循环中的下一个项目,但会产生错误。
我该怎么做才能使代码再次工作?