Entourage - Redirect Good Mail

Summary: Moves spam messages to the Spam folder and redirects good messages to another address.
Requires: SpamSieve, Entourage
Install Location: ~/Documents/Microsoft User Data/Entourage Script Menu Items/
Last Modified: 2019-10-02


Create a rule that executes this AppleScript, and use it instead of your normal Entourage spam rule. Then, the spam messages will be put in the Spam folder, and the good messages will be redirected to another account. For instance, you could leave this running on your Mac so that when you check your second mail account from the road—with a PowerBook or handheld—you don’t have to sift through the spam.

This script is not necessary with Entourage 2004, where you can do it by adding a rule that redirects messages that don't have the Junk category.

Installation Instructions · Download in Compiled Format · Download in Text Format


property redirectAddress : "address@domain.com"
property spamFolderName : "Spam" -- must be a local folder
property spamFolderContainerName : "" -- "" means On My Computer
property markSpamMessagesRead : false
property removeSpamMessagesFromServer : false
property tryToMoveIMAPMessages : false

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
set s to m's source
tell application "SpamSieve"
set isSpam to (looks like spam message s)
end tell
if isSpam 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
my moveToSpamFolder(m)
my redirectMessage(m)
end if
on error e
--display dialog "Error in Move Spam" default answer e
end try
end repeat
end tell

on moveToSpamFolder(m)
tell application "Microsoft Entourage"
if spamFolderContainerName is "" then
if not (exists folder spamFolderName) then
make new folder with properties {name:spamFolderName}
end if
set destFolder to folder spamFolderName
if not (exists folder spamFolderName of folder spamFolderContainerName) then
make new folder with properties {name:spamFolderName, parent:folder spamFolderContainerName}
end if
set destFolder to folder spamFolderName 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
set storage of m to destFolder
end if
end tell
end moveToSpamFolder

on redirectMessage(m)
tell application "Microsoft Entourage"
set newMessage to redirect m to redirectAddress without opening window
send newMessage
set read status of m to read
end tell
end redirectMessage