Outlook,规则向导,搜索包含制表符的文本?

Outlook,规则向导,搜索包含制表符的文本?

Changed by:{TAB}My Name我正在尝试在 Outlook 规则向导中搜索电子邮件正文。其中 {TAB} 是制表符。

但是,它似乎不允许我输入制表符。

我不能只搜索两个项目,Changed by:因为My Name我的名字出现了几次并且被改变为标准字段。

我正在使用 MS Office 2010

还有其他方法可以实现这个吗?

答案1

我可以在输入搜索字符串时按 Control+i 来嵌入制表符,但这无法匹配我邮件服务器上的邮件。当我检查收到的邮件正文中的实际字符时,我发现 {TAB} 字符实际上已被翻译成六个 \u00A0 (unicode) 字符,后跟一个空格字符。这导致搜索字符串无法匹配。您可能想先尝试这种方法,看看它是否适用于您的电子邮件。

作为替代解决方案,您可以通过向 Outlook 添加 Visual Basic for Applications 宏来创建“自定义”规则。

  1. 首先通过以下方式启用开发者菜单:Outlook -> 选项 -> 自定义功能区然后勾选开发人员选项中的主要标签列表上。
  2. 现在回到主 Outlook 视图,您应该会看到开发人员菜单,选择它
  3. 点击宏安全按钮,然后选择“通知所有宏”或“启用所有宏(不推荐;可能会运行潜在危险的代码)”
  4. 接下来点击Visual Basic功能区上的按钮打开 Visual Basic 编辑器
  5. 转到工具 -> 参考资料并添加对Microsoft VBScript 正则表达式 5.5图书馆
  6. 在 Visual Basic 编辑器中,选择此 Outlook 会话并粘贴下面列出的代码。
  7. 保存项目并退出 Outlook
  8. 重新打开 Outlook 并向自己发送测试消息

您需要编辑路由至文件夹名称RouteToFolderRegEx常量来匹配您的搜索偏好。

宏将保存到名为VBA项目位于您的用户设置区域(Windows 7 上的 C:\Users<用户名>\AppData\Roaming\Microsoft\Outlook\ 文件夹)。一旦宏按照您的要求运行,您可能希望备份此文件。

Option Explicit

Private WithEvents olInboxItems As Items

' This is the name of the folder you want your messages moved to Private Const RouteToFolderName As String = "FollowUp"

' This is the regular expression that matches the text you are ' searching for. Outlook replaced a single {TAB} character with ' 6 x \u00A0 characters and 1 x space character. Private Const RouteToFolderRegex As String = "Changed By:\u00A0+\s+Me"

Private Sub Application_Startup()
    Dim objNS As NameSpace
    Set objNS = Application.Session
    ' Attach the the Outlook inbox to receive an event whenever an item arrives
    Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
    Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
    Dim objNS As NameSpace
    Dim objMailItem As Outlook.MailItem
    Dim objMailFolderId As String
    Dim regex As RegExp
    Dim Found As Boolean
    
    ' Check to make sure we have a mail message first
    If (TypeOf Item Is Outlook.MailItem) Then
    
        ' Locate the id of the folder we want to store the message in
        objMailFolderId = FindFolderByName(Application.Session.folders, Found, RouteToFolderName)
        
        Set objMailItem = Item
    
        Set regex = New RegExp
        regex.IgnoreCase = True  ' Do a case insensitive search
        regex.Global = True
        regex.Pattern = RouteToFolderRegex
    
        ' Test the message body against the regular expression
        If (regex.Test(objMailItem.Body)) Then
            ' Message body matched so move to our folder
            objMailItem.Move Application.Session.GetFolderFromID(objMailFolderId)
        End If
    End If
End Sub

' Recursively search from the root folder for the folder that matches "folderName" (case insensitive)
Public Function FindFolderByName(ByRef folders As Outlook.folders, ByRef Found As Boolean, ByVal folderName As String) As String
    Dim objFolder As Outlook.Folder
        
    For Each objFolder In folders
        If Found = True Then
            Exit Function
        End If
        
        If LCase(objFolder.Name) = LCase(folderName) Then
            FindFolderByName = objFolder.EntryID
            Found = True
            Exit Function
        Else
            If objFolder.folders.Count > 0 Then
                FindFolderByName = FindFolderByName(objFolder.folders, Found, folderName)
            End If
        End If
    Next
End Function

答案2

尝试搜索Changed by:^tMy Name

如果这不起作用,请尝试在写字板中输入整个搜索字符串(包括普通制表符),然后剪切并粘贴到搜索中。

如果仍然不起作用,请执行相同的操作,但使用高级查找

答案3

您可以使用启用 NumLock 的数字键盘从键盘输入制表符。制表符的 ASCII 十六进制代码为“09”。按住 Alt 键并在数字键盘上输入“09”。当您释放 Alt 键时,将生成一个制表符。

相关内容