Mail.app automated 'sent messages' sorting by thread

Dear all

I have a couple of thousand of sent messages in my ‘sent messages box’ in Mail.app

I thought Applescript would help me to sort them by thread, i.e. iterating the message list, checking where the rest of the thread is in my many ‘projects’ mailboxes and move it there.

I’ve looked thoroughly on apple’s website and on this one, and it seems that Mail’s dictionnary does not have any call to find/search for related e-mails… am I naive to think this is a kind of straightforward thing to do? I don’t want to have to iterate through all my mailboxes, index all the messages, then link the outbox ones… is there something I miss

Thank you for your help

pa

Just to self document in case someone is interested…

I think Spotlight is the key. I found this amazing document:

http://macscripter.net/articles/460_0_10_0_C/

I will look into it and keep everyone posted… except if some senior coder can help us!

pa