Outlook, Rules Wizard, search text which includes tab character?

1

I'm trying to search for Changed by:{TAB}My Name in the body of an email in the Outlook Rules Wizard. where {TAB} is a tab character.

However, it doesn't appear that it will let me enter a tab character.

I can't just search for two items, Changed by: and My Name as my name appears several times and changed by is a standard field.

I'm using MS Office 2010

Is there another way to achieve this?

Jules

Posted 2012-04-19T09:27:03.747

Reputation: 381

Still looking for answer – Jules – 2012-05-10T08:18:36.063

Answers

1

I was able to embed a tab into the search string by pressing Control+i when entering it but this failed to match messages on my mail server. When I examined the actual characters in the message body of the received message I found that the {TAB} character had actual been translated into six \u00A0 (unicode) characters followed by a single space character. This prevented the search string from matching. You may want to try this method first to see if it works with your emails.

As an alternate solution, you can create a "custom" rule by adding a Visual Basic for Applications macro to Outlook.

  1. First enable the Developer menu by going to Outlook -> Options -> Customize Ribbon and then checking off the Developer option in the Main Tabs list on the right.
  2. Now back on the your main Outlook view you should see a Developer menu, select it
  3. Click Macro Security button on the ribbon and select either "Notification for all macros" or "Enable all macros (not recommended; potentially dangerous code can run)
  4. Next click the Visual Basic button on the ribbon to open the Visual Basic editor
  5. Goto the Tools -> References and add a reference to the Microsoft VBScript Regular Expression 5.5 library
  6. In the Visual Basic editor, select ThisOutlookSession and paste the code listed below.
  7. Save your project and exit Outlook
  8. Reopen Outlook and send yourself a test message

You will need to edit the string contents of the RouteToFolderName and the RouteToFolderRegEx constants to match your search preferences.

The macro is saved to a file called VBAProject.OTM located in your user settings area (C:\Users\\AppData\Roaming\Microsoft\Outlook\ folder on Windows 7). You may wish to make a backup copy of this file once you have gotten the macro working to your specifications.


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

user87883

Posted 2012-04-19T09:27:03.747

Reputation:

0

You can enter a tab character from the keyboard by using the number pad with NumLock engaged. The ASCII hexadecimal code for the tab character is "09". Hold down the Alt key and type "09" on the number pad. When you release the Alt key a tab character is generated.

Dutch Waterman

Posted 2012-04-19T09:27:03.747

Reputation: 1

0

Try searching for Changed by:^tMy Name.

If that doesn't work, try typing the whole search string, including the normal tab character, in WordPad, then cutting and pasting into search.

If that still doesn't work, then do the same thing but using Advanced Find.

Old Pro

Posted 2012-04-19T09:27:03.747

Reputation: 1 751

Didn't work :(, I don't want to have to use advanced find each time – Jules – 2012-05-01T12:46:06.337