-- Downloaded From: http://c-command.com/scripts/spamsieve/apple-mail-save-spam -- Last Modified: 2007-08-17 on getSpamFolder() tell application "SpamSieve" set theKeys to {"AppleMailTrainSpamName"} set theDefaults to {"Spam"} set {spamFolderName} to lookup keys theKeys default values theDefaults end tell tell application "Mail" if spamFolderName is "" then return return mailbox spamFolderName end tell end getSpamFolder on writeToFileNamed(s, theName) set theFolder to do shell script "echo ~/Desktop/Spam/" try do shell script "mkdir " & theFolder's quoted form end try set theFile to theFolder & theName try do shell script "echo " & s's quoted form & ">" & theFile's quoted form end try end writeToFileNamed tell application "Mail" set theMessages to every message of my getSpamFolder() repeat with m in theMessages my writeToFileNamed(m's source, "Message " & m's id) -- delete m end repeat end tell