Hello Applescript List members;
First time poster and relative newbie here.
I've written a script that searches for messages, in a particular mailbox, that are older than a couple of days and then deletes them.
The script generally works except I usually have to run it two or three times before it picks up ALL of the messages that fall into the
'older than 2 days' category.
The snippet of relevant code is below and any pointers towards what may be wrong would be heavily appreciated.
Btw - I'm running Mountain Lion and the included Apple Mail program. I have 4GB RAM and plenty free HD space.
Thanks in advance
Robert.
tell application "Mail" set fetches automatically to false set selectedMessages to (messages of mailbox "Spam Virus Mail" of mailbox "Personal" whose date received is less than today - (2 * days)) set messcount to (count of selectedMessages) if (count of selectedMessages) is equal to 0 then tell application "Finder" activate display alert "No mail in the Spam Virus Mail mailbox is older than 2 days" message "Try running this script later on. Rob." giving up after 2 end tell else try repeat with i from 1 to messcount set theSource to item i of selectedMessages set background color of theSource to red delete theSource end repeat
|