更频繁地运行仅限客户端的 Outlook 规则

更频繁地运行仅限客户端的 Outlook 规则

我的 Outlook 规则规定将电子邮件移动到文件夹并通知我其中的一些。因此我必须依赖仅针对客户端的规则。

但是,我经常看到邮件被接收到收件箱文件夹和被移动到文件夹之间存在延迟,这是在客户端专用规则中指定的。

如何增加规则运行的频率?理想情况下,我希望在收到新消息时立即运行客户端专用规则。 Outlook Version 2005 (Build 12827.20336 Click-to-Run)

UPD:这是我的其中一条规则的示例:

Apply this rule after the message arrives
with example.com in the recipient's address
move it to Example folder
  and Display a Desktop Alert
  and stop processing more rules

答案1

正如 Zina 上面提到的,当您设置“邮件到达后应用此规则”时,Outlook 规则将在 Outlook 每次收到邮件时应用。请检查所有规则的状态,看看它们是否都已正确启用。

答案2

我可以通过启用 Visual Basic 并使用Application_NewMail事件运行规则来解决这个问题。这使得规则在每次邮件接收操作后真正运行。

有关如何为 Outlook 启用 Visual Basic 的说明,请参阅这个超级用户的回答或者本图解说明

在 Outlook 的 Visual Basic 编辑器中添加一个模块并粘贴以下代码:

Sub RunRules(ColRules As Object)

    Dim myRule As Outlook.rule      

    For Each myRule In ColRules
        ' Rules we want to run
        myRule.Execute ShowProgress:=False
        Debug.Print myRule.name
        
        ' Actually, this is strange, because it processess every item, so should stop on the first rule, which has such condition
        Dim oAction As Outlook.RuleAction
        For Each oAction In myRule.Actions
            If oAction.Enabled = True Then
                If oAction.ActionType = olRuleActionStop Then
                    Exit For
                End If

                'add more actions here
            End If
        Next
        
    Next
    Exit Sub
End Sub

Public Sub RunAllRules()

  Dim ColRules As Outlook.Rules
  Dim ErrDesc As String
  Dim ErrNum As Long
  Dim InxStoreCrnt As Long
  Dim RuleCrnt As Outlook.rule

  With Session
    For InxStoreCrnt = 1 To .Stores.Count
      With .Stores(InxStoreCrnt)
        Debug.Print .DisplayName
        Set ColRules = Nothing
        On Error Resume Next
        Set ColRules = .GetRules()
        ErrNum = Err.Number
        ErrDesc = Err.Description
        On Error GoTo 0
        If ErrNum <> 0 Then
          Debug.Print "  " & ErrNum & " " & ErrDesc
        Else
          If Not ColRules Is Nothing Then
            If ColRules.Count = 0 Then
              Debug.Print "  no rules in this store"
            Else
              Call RunRules(ColRules)
            End If
          Else
            Debug.Print " No error but GetRules returned Nothing"
          End If
        End If
      End With
      Set ColRules = Nothing
    Next
  End With

End Sub

然后将以下内容粘贴到您的Microsoft Outlook Objects→中ThisOutlookSession

Private Sub Application_NewMail()
    RunAllRules
End Sub

相关内容