Wednesday, August 28, 2013

Automate Mail Depuration

Sometimes Apple Mail rules are not enough, so we have AppleScript to do whatever we want, this is how i automate mine:

tell application “Mail”

set |messages| to messages of mailbox “Inbox” of account “MyAccount”
repeat with |message| in |messages|
set |one day| to (30 * days)
set |date limit| to ((current date) – |one day|)
if date received of |message| is less than |date limit| and flagged status of |message| is false then
move |message| to mailbox “OldMail/Inbox” –on my mac
end if
end repeat

set |messages| to messages of mailbox “Spam” of account “MyAccount”
repeat with |message| in |messages|
set |one day| to (1 * days)
set |date limit| to ((current date) – |one day|)
if date received of |message| is less than |date limit| and flagged status of |message| is false then
delete |message| –account trash
end if

end tell

Source: http://luizsiqueiraneto.tumblr.com/post/26988382255/how-to-periodically-move-to-trash-old-messages, http://hints.macworld.com/article.php?story=20081019114709793

No comments: