Search Folders for arbitrary email headers in Outlook

4

2

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

Posted 2013-11-21T00:16:28.897

Reputation: 3 478

I don't see why not. What have you tried? – None – 2013-11-21T00:31:54.587

@RandolphWest, in the Advanced tab in the Search Folder Criteria, I can select a field from the Field drop-down list, but none of them seem appropriate. I can paste my header in the box under Field, but then I can't select a Condition. The More Advanced button is grayed. – dangph – 2013-11-21T00:47:05.157

Answers

4

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

Posted 2013-11-21T00:16:28.897

Reputation: 41

Like cpow and the OP, dangph, I do so wish we could simply have a field in the search folders interface for the message header, like we do in rules.

cpow's trick (to use a rule to assign a category and then use a search folder to find that) is better than nothing, and people needing this capability should surely note it. Thanks for sharing.

But I would love to hear if a) there was some way to search headers in search folders that we are missing, or b) that this was (or will be) added in a later rev of outlook. I'm on 2010. @dangph is on 2007. Can't tell what cpow is using. – charlie arehart – 2014-09-05T14:51:46.040

cpow is using Outlook 2007 (edited my answer to reflect this) but I will probably soon be on 2010 or later. I certainly hope MS incorporates header searching at some point. Unless you're in a closed environment where only internal Exchange email is flowing then you're going to have at least some messages with headers, at which point having such a search feature would be worthwhile. You'd think that since the capability is there for rules that the framework is already in place that the search functions could hook into. – cpow – 2015-06-15T17:35:43.040

As of 2019, it's still not possible to use the "Advanced Find" feature to search against message headers, and this is with the latest version of Outlook 365. Grr. (And yes, it is and has long been possible to setup a rule based on searching the header, but sometimes we don't want to manage such an email based on a rule looking at headers, but instead just to search for such email.) – charlie arehart – 2019-08-26T15:48:10.080

3

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.

Justin Brown

Posted 2013-11-21T00:16:28.897

Reputation: 71