Oct 21, '04 11:06:00AM • Contributed by: leenoble_uk
tell application "Mail"
set theSubjectList to {}
set themessages to selection as list
repeat with msg in themessages
set thisSubject to (subject of msg as string)
if thisSubject is not in theSubjectList then
set theSubjectList to theSubjectList & {thisSubject}
end if
end repeat
set theNewSubject to ¬
(choose from list theSubjectList with prompt ¬
"Choose the subject of the merged thread…") as string
if theNewSubject is in theSubjectList then
repeat with msg in themessages
set subject of msg to (theNewSubject)
end repeat
else
display dialog "Action cancelled"
end if
end tell
Save this AppleScript in ~/Library -> Scripts -> Mail Scripts, and it will appear in the script menu in Mail. There are a couple of caveats, though. In order to see the reorganised threads, you have to unorganise and then organise again from the View menu. I tried it with scripting, but UIScripting doesn't work while the script menu is being used, and I couldn't get the proper commands to do it, either.
The other oddity with this is that as soon as you close the message list window and open it again, you lose all your changes ... unless you wait a long time. I think Mail must perform some kind of indexing on the messages, and I don't know how to force this to occur any quicker. But leave the window open (and the shortest time I've successfully left it is two hours!), and the alterations will stick for the longer term. Your mileage may, of course, vary. If your AppleScript knowledge is superior, then you may be able to fix these issues.
