以下脚本针对收件箱文件夹执行单个规则,但不执行子文件夹。如何运行它,就像我检查了"包括所有子文件夹"手动运行时复选框?
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
答案 0 :(得分:0)
根据this page,IncludeSubfolders
方法有一个Rule.Execute
参数。所以试试:
rl.Execute ShowProgress:=True, IncludeSubFolders:=True