Scenario 1: I have several contacte with multiple email accounts, and they use different "names" for each account. I want to "clump" all their messages together by sorting on something. No way in standard Poco, AFAIK.

Scenario 2: I have a big mailing list, and I want to strip out the duplicates. Very difficult, since I might have several different contact records with the same email address.

The following script addresses these and other scenarios. Basically, it adds 2 X-headers to the message, and then uses the custom column display capability to show nickname and email address. It requires multiple address book entries, one per email address (but with the same nickname), in order to get the "clumping" I need in scenario 1.

It can be run manually on an existing mailbox, or set up as an incoming filter. It also works on an OnAdd event

{Script to add headers to messages containing nicknames{and raw email address. Used in conjunction with the custom{column display, they allow the splitting of the nickname{and the email address into 2 separate columns. In addition,{'my' name for a contact is displayed in preference to {the name selected by the contact in the incoming email.{This can be set up as an incoming filter, or run manually.{Not tested: it should also work with an event.{Placed into the public domain by Frazmi on 25 August 2004{Please test thoroughly and over and over before you use this{on a production basis. The standard 'FrazWarranty' applies:{It works on my system. It might fail on yours.{{Revision 1 -- Fixed bug pointed out by Hoygt. If run on message{in Sent folder, and there are multiple addressees, the original{script added "header" lines with no header prefix. This revision{concatenates all the "to" addresses into a single line.{{Revision 2 -- Changed the last code block to use the variables{for EmailHeader and NicknameHeader -- they were hard coded.{Also added the line "ExtractEmail $Email" in the section :OUTGOING{which had been inadvertently deleted in the previous bug fix.

Theres one tiny problem with the script but its nothing major. If the to header has multiple recipients and the script is run on that message in the sent mailbox then the new x-poco-email header has a small problem. I think maybe it needs commas at the end of each line since if i re-run the script on that message the first line of the x-poco-email header is removed but it leaves the rest of the header as it is, and then duplicates it again, leaving a bit of a mess. So after two runs i get the headers:

Two other bugs needed squashing. When I edited the first version of the script, somehow a line got dropped. And the last code block didn't use the variables that hold the header names.

I've changed the header name to X-Nickname and X-Email in order to fix a display problem when the Poco display font is large. But you can set them to anything you want.

One caution, once you've set the header names, re-running the script will not catch and delete the headers if you change the header names. You would have to modify the script in such an event. In other words, test it a lot before you use it on "real" messages.