-- Entourage - Separate by Score -- https://c-command.com/scripts/spamsieve/entourage-separate-by-score -- Summary: Moves very spammy messages to the Spam folder and less spammy ones to the Possible Spam folder. -- Requires: SpamSieve, Entourage -- Install Location: ~/Documents/Microsoft User Data/Entourage Script Menu Items/ -- Last Modified: 2019-05-24 property spamFolderName : "Spam" -- must be a local folder property possibleSpamFolderName : "Uncertain Spam" -- must be a local folder property spamFolderContainerName : "" -- "" means On My Computer property markSpamMessagesRead : false property removeSpamMessagesFromServer : false property tryToMoveIMAPMessages : false property threshold : 90 tell application "Microsoft Entourage" if not (exists category "Junk") then make new category with properties {name:"Junk", color:{29952, 29952, 29952}} end if set msgs to current messages -- doesn't work without temp variable repeat with m in msgs try set s to m's source tell application "SpamSieve" set theScore to score message s end tell if theScore >= 50 then set category of m to {category "Junk"} if markSpamMessagesRead then set read status of m to read if removeSpamMessagesFromServer and m's online status is fully downloaded then set connection action of m to remove at next connection if theScore > threshold then my moveToSpamFolder(m, spamFolderName) else my moveToSpamFolder(m, possibleSpamFolderName) end if end if on error e --display dialog "Error in Move Spam" default answer e end try end repeat end tell on moveToSpamFolder(m, folderName) tell application "Microsoft Entourage" if spamFolderContainerName is "" then if not (exists folder folderName) then make new folder with properties {name:folderName} end if set destFolder to folder folderName else if not (exists folder folderName of folder spamFolderContainerName) then make new folder with properties {name:folderName, parent:folder spamFolderContainerName} end if set destFolder to folder folderName of folder spamFolderContainerName end if if tryToMoveIMAPMessages then set {theAccount, theSource, theClass} to m's {account, source, class} set ifRead to read status of m make new incoming message at destFolder with properties {account:theAccount, source:theSource, read status:ifRead} delete m else set storage of m to destFolder end if end tell end moveToSpamFolder