|
|
A script to (somewhat) merge threads in Mail.app
I fixed the script after I submitted it. One additional line fixes both issues.
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
move msg to mailbox "INBOX" of account of mailbox of msg
else
display dialog "Action cancelled"
end if
end tell
but it only works in your inbox. I'm sure someone can alter it to work in any mailbox. ---
A script to (somewhat) merge threads in Mail.app
This version lets you type in whatever you like for the subject...
tell application "Mail"
set theSubjectList to {}
set themessages to selection as list
set messageTitle to button returned of (display dialog "Thread name…" buttons {"New", "Select From Existing…"} default button 2)
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
if messageTitle is "New" then
set theNewSubject to (text returned of (display dialog "Type new subject" default answer "NEW THREAD")) as string
else
set theNewSubject to (choose from list theSubjectList with prompt "Choose the subject of the merged thread…") as string
end if
if theNewSubject is not "false" then
repeat with msg in themessages
set subject of msg to (theNewSubject)
move msg to mailbox "INBOX" of account of mailbox of msg
end repeat
else
display dialog "Action cancelled"
end if
end tell
---
A script to (somewhat) merge threads in Mail.app
OK, Final version. Lets you choose or type and includes options to rename the message to what it was called originally, providing it is held within the header text.
tell application "Mail"
set theSubjectList to {}
set headList to {}
set themessages to selection as list
set messageTitle to button returned of (display dialog "Thread name…" buttons {"New", "Select From Existing…"} default button 2)
repeat with msg in themessages
set theHeaders to headers of msg as list
set thisSubject to (subject of msg as string)
repeat with head in theHeaders
if (name of head as string is "Thread-Topic") and (content of head as string is not in theSubjectList) then
set theSubjectList to theSubjectList & {(content of head as string)}
else if thisSubject is not in theSubjectList then
set theSubjectList to theSubjectList & {thisSubject}
end if
end repeat
if thisSubject is not in theSubjectList then
set theSubjectList to theSubjectList & {thisSubject}
end if
end repeat
if messageTitle is "New" then
set theNewSubject to (text returned of (display dialog "Type new subject" default answer "NEW THREAD")) as string
else
set theNewSubject to (choose from list theSubjectList with prompt "Choose the subject of the merged thread…") as string
end if
if theNewSubject is not "false" then
repeat with msg in themessages
set subject of msg to (theNewSubject)
end repeat
move msg to mailbox "INBOX" of account of mailbox of msg
else
display dialog "Action cancelled"
end if
end tell
It also only needs to do the move message line once on a single message, after the renaming is complete. --- |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.10 seconds |
|