您如何 运行 针对不同商店的规则?

How can you run a rule against a different Store?

您如何 运行 针对不同商店的规则?

我可以使用 ...

访问我的规则并从默认存储执行它们
Set storeRules = Application.Session.DefaultStore.GetRules()
For Each storeRule In storeRules
    If storeRule.name = name Then
        storeRule.Execute ShowProgress:=True
    End If
Next

但我看不到如何对共享帐户使用规则。

我可以手动 运行 通过 Outlook 客户端,"Run Rules Now",select "Run In Folder" 浏览器中的正确文件夹

更新:

尝试遍历我所有的商店,我有三个商店。 ExchangeStoreType 是一个 0- 主 Exchange 邮箱,一个 2-Exchange public 文件夹(PF?)和一个 1-Exchange 代理邮箱。我正在尝试 运行 最后一个规则,但是委托文件夹中的 .GetRules 没有找到任何规则

Sub RunTest()
Dim storeRules As Outlook.Rules
Dim storeRule As Outlook.Rule
Dim allStores As Outlook.stores
Dim myStore As Outlook.Store

Set allStores = Application.Session.stores
For Each myStore In allStores
    On Error Resume Next
    Debug.Print myStore.DisplayName & "  " & myStore.ExchangeStoreType
    Set storeRules = myStore.GetRules()
    For Each storeRule In storeRules
        Debug.Print "... store: " & storeRule.name
    Next
Next
End Sub

然而,如果我通过 Outlook UI 和 select 存储

,我可以 运行 规则

不使用 Application.Session.DefaultStore,而是使用 Application.Session.Stores 集合访问相关商店。