Entourage - Vacation Message

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

Description

If you have Entourage 2004, instead of using this script you should setup two SpamSieve rules and then create a third that says “If All messages Then Reply” and set the Reply Text to your vacation message.

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, Entourage will reply to the good messages with an e-mail saying that you are on vacation.

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

Script

property vacationMessage : "I'm out of town and will read and respond to your message when I return."
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
        
try
            
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)
            
else
                
my replyToMessage(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
        
else
            
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
        
else
            
set storage of m to destFolder
        
end if
    
end tell
end moveToSpamFolder

on replyToMessage(m)
    
tell application "Microsoft Entourage"
        
set newMessage to reply to m without opening window
        
set content of newMessage to vacationMessage
        
send newMessage
    
end tell
end replyToMessage