为什么运行所有已启用规则的代码无法在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开头。或不。它只是不会转到循环中的下一个项目,但会生成错误。
如何让代码再次运行?
答案 0 :(得分:0)
如果某些规则标记为“来自其他计算机”,请检查规则向导。 如果您有这样的话,那么代码将在以下行中断:
For Each currentRule In rules
我现在也遇到同样的问题 - 带我进行了大量的故障排除来解决这个问题。还有一件事可能是一个问题:如果任何规则被破坏,例如引用一个不存在的目录,规则对象将不包含任何规则。
如果对上述问题进行排查,请删除所有可疑规则并开始逐个添加。