vba - 如何在多个帐户上运行规则?
问题描述
我之前询问过如何让规则适用于多个帐户。已部分回答,但规则不适用于第二个帐户。
运行脚本时会弹出进度窗口,但不运行任何规则。
规则的调试输出列出了帐户的所有规则。如果我手动运行规则,它确实有效。
决定将宏一分为二。运行第一个宏适用于第一个帐户。但是第二个帐户的第二个宏不起作用。
我的假设是它试图在第一个帐户上运行这些规则,但没有成功,因为这些规则不存在。
Sub RunTest_AccountOne()
Dim storeRules As Rules
Dim storeRule As Rule
Dim allStores As Stores
Dim myStore As Store
Dim emailaccount As String
Set allStores = Session.Stores
emailaccount = "example@example.com.au"
For Each myStore In allStores
'On Error Resume Next
'If needed, place just before the expected error.
'Follow closely with On Error GoTo 0 to return to normal error handling.
'Debug.Print myStore.DisplayName & " " & myStore.ExchangeStoreType
Select Case myStore.DisplayName
Case emailaccount
'Debug.Print " ExchangeStoreType matched: " _
& myStore.DisplayName & " " & myStore.ExchangeStoreType
Set storeRules = myStore.GetRules()
For Each storeRule In storeRules
'Below only works if it is the first account added to Outlook.
'storeRule.Execute 'ShowProgress:=False
'Below shows the progress window for rules running, but doesn't apply anything.
storeRule.Execute ShowProgress:=True, Folder:=myStore.GetDefaultFolder(olFolderInbox), RuleExecuteOption:=olRuleExecuteAllMessages
'Below outputs a bunch of "Inbox" messages in the console, which coincides with the amount of rules, as expected.
'Debug.Print myStore.GetDefaultFolder(olFolderInbox)
Next
End Select
Next
End Sub
我试过RuleExecuteOption:=olRuleExecuteAllMessages
有无。
解决方案
推荐阅读
- r - acf() 函数绘制非常大的滞后
- docker - GKE 无法从 GCR 中提取图像
- php - CORS 问题 Angular + PHP REST API
- python - 必须调用 ray.init() 两次:第一次给出“AUTH
在没有为默认用户配置任何密码的情况下调用。” - sql - GitLab 管道错误:包 'mysql-client' 没有安装候选。我能做些什么?
- excel - 使用 vba 打开/保存 excel 文件时隐藏标准进度条
- firebase-authentication - 如果用户仍然存在于具有 OpenID Connect 的身份提供者上,身份工具包是否会重新验证
- dataset - 如何从 Foundry 中的代码存储库编写或创建外部数据集
- reactjs - 如何在 AWS CodeBuild 中为 MERN 堆栈应用程序配置 buildspec.yml
- javascript - writeQuery 中的 Apollo @connection 指令不清除分页列表