8

I would like to create a Search Folder in Outlook for a non-standard email header. Namely this one:

X-Bugzilla-Changed-Fields: Status Resolution

Is it possible to search on such headers? I'm using Outlook 2007.

dangph
  • 5,093

3 Answers3

5

I was trying to do the same recently and in searching the web encountered your question. I too failed to find any way to use the search folder to check headers. My assumption is because internet headers aren't really an "Exchange field", meaning that I don't believe any "intranet" email sent within the Exchange server itself (like that email you sent with the funny cat picture [LOLZ!] to your co-worker...) has such headers. But here is the workaround I came up with that I'm using.

I set up a new rule in the rules wizard that on receipt of new messages to check the headers. If a specific string is found then assign the message to a specific category. In my case I'm looking for messages that come from our Best Practical Request Tracker server, in each of those headers is the string "RT-ticket:". If my rules find this string in the header they then assign the message to a category I created named "RT Tickets". (I created this category with no color so it is less obtrusive.) I can then create a search folder that looks for messages of just that category. Extra steps but problem solved. I've done this in Outlook 2007 but it should work in any version of Outlook that supports the rules wizard checking headers and then assigning to categories.

The drawbacks to this are 1) yet another rule in my growing list, and 2) if I want to apply this to emails already received I'll need to go through and manually run the rule against those folders first. At this point I'm only concerned about new messages presently in my inbox or those arriving going forward so I simply set the rule to run at the time of creation and that was taken care of. A discovered benefit of using the categories though is that you can have it display as a column in your message list. I'm not sure I'll even be using the search folders as I had intended, I may just go and sort my inbox by category in order to find the desired messages.

If anyone needs the steps of creating a rule expanded I can do so, just leave a comment. I would hope though that if one is knowledgeable enough to be digging around in internet email headers that creating an Outlook rule would be old-hat. The wizard they have is pretty straightforward.

cpow
  • 53
5

This PowerShell script searches all headers in Inbox for a match. It may take a while to run, depending on your inbox size. Some caveats apply, not the least of which is a possible residual outlook.exe process. This could be killed either manually in Task Manager, or programmatically via get-process "outlook" | kill. It's assumed you have access to PoweShell because of its near ubiquity, however the particular OS you are using could have limited support for this.

$MatchString = "X-Mailer: YahooMailWebService/0.8.201.700"
Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
$namespace = new-object -comobject outlook.application
$MAPI = $namespace.GetNamespace("MAPI")
$Inbox = $MAPI.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox).Items
$Headers = `
    foreach ( $MailItem in $Inbox ) { 
        $MailItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E") 
    }
$namespace.Quit()
$MatchingHeaders = $Headers | where { $_.contains( $MatchString ) }
#sample output
$MatchingHeaders | Select-Object -First 1

If there is a nonzero set of matches, something like the following is returned.

Received: from q0plumsmtp03-06.purd.phy5.mysrver.net (68.178.213.11) by q0PWrc6HT002.rc6.mysrver.net (148.168.131.21) with Microsoft SMTP Server id 14.2.18.1; Wed, 13 Aug 2014 18:42:57 -0700 [...]

You can then change the $MatchString assignment to the header string you're looking for. If you want to generalize the search using regular expressions, PowerShell makes that possible too.

1

Hard to believe that 10 years later (in 2024, and on the latest Outlook release) it remains impossible to use Outlook's "Advanced Find" (and the related "Search Folder") feature to search for messages based values in the message header--even though the Outlook "Rules" feature has offered the ability to search this all along. (This is on Office 356 v2405, as I write this.)

Unfortunately, the only 2 answers offered since 2014 are only workarounds, rather than explaining how to solve this problem only with Advanced Find. Let me clarify for future readers finding this.

The answer suggesting powershell may well help those wanting to search for messages OUTSIDE of Outlook, but it's not involving Outlook's Advanced Find feature.

And the other answer suggesting to setup an outlook RULE is indeed "better than nothing" (as I wrote in reply in 2014 here), at least for those who want to setup such a rule (and then point a search folder at that), but that two-step process may not appeal to all.

Finally, for those unfamiliar with this "Advanced Find" feature, you can use ctrl+shift+f to open it (at least in the Desktop version of Outlook), allowing searches using many pre-defined fields. Then it also offers an "advanced" tab, where one can choose a category to find many more Outlook fields that can be searched. And it's that list (even under "all mail") where we are never finding an option to choose to search the message headers. For more, here's an MS doc page on the feature, including screenshots--and another way to launch the tool.

Maybe someday someone will come along and tell us that MS has finally acceded to our wish...or perhaps they'll tell us what we're missing if it can be done already and we've been missing it!