tell application "Mail" set v to first message viewer set a to messages of v get count of a set selected messages of v to {} set mids to {} set s to a reference to mids repeat with eachMessage in a set i to message id of eachMessage if mids contains i then if (count of selected messages of v) > 0 then set selected messages of v to (selected messages of v & {eachMessage}) else set selected messages of v to {eachMessage} end if else copy i to the end of s end if end repeat beep display dialog "Finished selecting duplicate messages" buttons {"OK"} with title "Select Duplicates Script" end tell