Outlook – Searching by message-id in Outlook


Is there a way to search by message-id in Outlook when it's connected to a generic IMAP server? Alternatively, is there a way to search for the message-id in the downloaded .pst file? I've done quite a bit of searching on this and I haven't found a way to do this with just Outlook and not Exchange.

Best Answer

You have three options:

  1. Search in the selected folder only. Customize current folder view or create a new one, click "Filter" and go to "SQL" tab in its settings. Set the "Edit these criteria directly" check and type the following:

    http://schemas.microsoft.com/mapi/proptag/0x1035001F = 'message-id-to-search'

    this will restrict message list to messages that have the "message-id-to-search" Message-ID.

  2. Advanced search. You'll need to create a VBA macro for that. Good news it that it's only two functions long. In Outlook VBA editor (ALT+F11), open Project1 -> Microsoft Outlook Objects -> ThisOutlookSession and create at least two Subs. Something like these ones:

    Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
        If SearchObject.Tag = "MessageId" Then
            Set Results = SearchObject.Results
            MsgBox "Message-ID search complete. " & Results.Count & " result(s) found."
            For i = 1 To Results.Count
        End If
    End Sub
    Public Sub SearchMessageId()
        Set Folder = Session.PickFolder
        If Not Folder Is Nothing Then
            r = MsgBox("Include subfolders?", vbYesNoCancel, "Search by Message-ID")
            If r <> vbCancel Then
                MessageId = InputBox("Message-ID:")
                If MessageId <> "" Then
                    Application.AdvancedSearch "'" & Folder.FolderPath & "'", "http://schemas.microsoft.com/mapi/proptag/0x1035001F = '" & MessageId & "'", r = vbYes, "MessageId"
                End If
            End If
        End If
    End Sub
  3. Use Outlook rules. I mean "with specific words in the message header" rules. Disable them and run manually when needed to copy found messages or tag them with a flag and/or category. Do not forget to edit message-id to search for before each run!

Related Question