An AppleScript to move/delete old Entourage emails

Aug 19, '04 09:38:00AM

Contributed by: fresler

I have Entourage set up with multiple folders for the various people I receive email from. There are some people for whom I want to keep their emails for a certain number of days before I delete them, while others I don't care about keeping. So, I wrote the following AppleScript which looks through my folders (excluding some) and finds emails older than 60 days. The script then moves those emails to Deleted Items.

tell application "Microsoft Entourage"
  repeat with theFolder in every folder
    set theCurrentFolder to theFolder
    set folderName to the name of theCurrentFolder
    if folderName is not equal to "Keep" and folderName ¬
    is not equal to "Deleted Items" and folderName is not equal to ¬
    "Archive" and folderName is not equal to "Sent Items" then
      display dialog "Processing folder " & folderName
      repeat with theMessage in every message in the folder folderName
        set theCurrentMessage to theMessage
        try
          set theDate to time received of theMessage
          set difference to ((current date) - theDate) div days
          if difference is greater than 60 then
            move theMessage to folder "Deleted Items"
          end if
        end try
      end repeat
    end if
  end repeat
  display dialog "Done!"
end tell
The lines in the script you'd want to modify are: You may also want to delete display dialog "Processing folder " & folderName. I have that in there so I know which folder is currently being processed.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040818114948350