I've written a script that is invoked by a Mail rule. I want the script to move messages to the trash under certain conditions. It didn't work so I've commented out the test and it still didn't work. I got the code from an online tutorial. The tutorial moved the message to "Filed". The rule itself worked when I replaced the call to the script with a move to the trash. Here's what I'm testing:
using terms from application "Mail"
on perform mail action with messages these_messages for rule this_rule
tell application "Mail"
set the message_count to the count of these_messages
repeat with i from 1 to the message_count
set this_message to item i of these_messages
-- try
-- set this_content to (every character of content of this_message) as Unicode text
-- if this_content is in {"", "?"} then error
-- if "bowles" is not in this_content and "patton" is not in this_content then
set mailbox of this_message to mailbox "Trash"
-- end if
-- on error error_message
-- set this_content to "NO CONTENT"
-- end try
end repeat
end tell
end perform mail action with messages
end using terms from
The statement at issue is: set mailbox of this_message to mailbox "Trash"
The rest of the active code was from AppleScript Editor template.
Thanks, Curt
P.S. Are there any books out there that deal with using AppleScript with Mail?