• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Delete Mail Script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Delete Mail Script


  • Subject: Delete Mail Script
  • From: Robert <email@hidden>
  • Date: Wed, 07 Aug 2013 01:02:02 +0100

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 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Delete Mail Script
      • From: Deivy Petrescu <email@hidden>
    • Re: Delete Mail Script
      • From: Steve Bird <email@hidden>
    • Re: Delete Mail Script
      • From: David Ferrington <email@hidden>
    • Re: Delete Mail Script
      • From: Brian Christmas <email@hidden>
    • Re: Delete Mail Script
      • From: Jean Suisse <email@hidden>
  • Prev by Date: Moving & deleting a mailbox in Mail
  • Next by Date: Re: Delete Mail Script
  • Previous by thread: Re: How can I speed up execution time of this script in case of many files
  • Next by thread: Re: Delete Mail Script
  • Index(es):
    • Date
    • Thread