Vba 如何对Outlook收件箱中的所有子文件夹执行以下脚本?

Vba 如何对Outlook收件箱中的所有子文件夹执行以下脚本?,vba,outlook,exchange-server,Vba,Outlook,Exchange Server,以下脚本对收件箱文件夹(而不是子文件夹)执行单个规则。手动运行时,如何像选中“包含所有子文件夹”复选框一样运行它 Sub RunAllInboxRules() Dim st As Outlook.Store Dim myRules As Outlook.Rules Dim rl As Outlook.Rule Dim runrule As String Dim rulename As String rulename = "MarkNonEmplo

以下脚本对收件箱文件夹(而不是子文件夹)执行单个规则。手动运行时,如何像选中“包含所有子文件夹”复选框一样运行它

Sub RunAllInboxRules()
    Dim st As Outlook.Store
    Dim myRules As Outlook.Rules
    Dim rl As Outlook.Rule
    Dim runrule As String
    Dim rulename As String

    rulename = "MarkNonEmployeeMailAsRead"

    Set st = Application.Session.DefaultStore
    Set myRules = st.GetRules

    For Each rl In myRules
        If rl.RuleType = olRuleReceive Then
            If rl.Name = rulename Then
                rl.Execute ShowProgress:=True
                runrule = rl.Name
            End If
        End If
    Next

    ruleList = "This rule was executed against the Inbox:" & vbCrLf & runrule
    MsgBox ruleList, vbInformation, "Macro: RunAllInboxRules"

    Set rl = Nothing
    Set st = Nothing
    Set myRules = Nothing
End Sub
根据,有一个
IncludeSubfolders
参数用于
规则。执行
方法。因此,请尝试:

rl.Execute ShowProgress:=True, IncludeSubFolders:=True