I wrote an AppleScript that moves selected emails to the Trash. The script works fine in that regard. The problem is that the emails remain on the server. Is there additional code I need to add to get it to do that? Here's the code:
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 message_count to 1 by -1
set this_message to item i of these_messages
set this_content to (every character of content of this_message) as Unicode text
if "bowles" is not in this_content and "patton" is not in this_content then
set theAccount to account of mailbox of this_message
set mailbox of this_message to mailbox "Trash" of theAccount
end if
end repeat
end tell
end perform mail action with messages
end using terms from