错误:2020.05.26 - 自上次 Microsoft 更新以来,代码在规则设置为“通过指定帐户”时失败。
当它袭来时
Set olRule = olRules.Item(i)
它抛出:
运行时错误'-2146664191 [800c8101]
Private Function FindRule(strRuleName As String) As Boolean
'error handler
On Error GoTo ErrorHandler
'default process boolean to failed
FindRule = False
'open rules object
Set olRules = Outlook.Application.Session.DefaultStore.GetRules
'loop through rules to see if the rule is in the rules list
If olRules.Count = 0 Then
'no rules, so it can't exist
FindRule = False
Else
'check the list of rules
'For i = olRules.Count To 1 Step -1
For i = 1 To olRules.Count
Set olRule = olRules.Item(i)
If olRule.Name = strRuleName Then
FindRule = True
Exit For
End If
Next i
End If
'rule not found. let folks know
If FindRule = False Then
Err.Raise 60001, "Rule Error", "Rule not found!"
End If
ExitFunction:
'skip error handler
Exit Function
ErrorHandler:
'display error
MsgBox Err.Description, vbExclamation + vbOKCancel, "FindRule - Error: " & CStr(Err.Source)
'clear error
Err.Clear
'return failed boolean
FindRule = False
End Function
OnError Resume Next
不允许继续执行。
删除“通过指定帐户”规则即可允许代码执行。
错误为
E_ACCT_NOT_FOUND
,表示规则引用的账户不再存在。编辑规则并将其指向右侧
帐户。
解决了!
找到了答案解决方案是删除注册表项:Computer\HKEY_CLASSES_ROOT\WOW6432Node\CLSID{0006F03A-0000-0000-C000-000000000046}