• 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
Clearing 'sticky' mail in Mail app.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Clearing 'sticky' mail in Mail app.


  • Subject: Clearing 'sticky' mail in Mail app.
  • From: Brian Christmas <email@hidden>
  • Date: Mon, 15 Jun 2015 07:42:46 +1000

G’day scripters

Some weeks ago a gentleman asked for help with email in the Mail app Mail Boxes not clearing properly.

I replied (and have lost his address), but forgot to add that my code adds a ‘delete’ command, which in turn was curtesy of another lister.

So, here’s the full code as I’ve used it in my app.

Regards

Santa



tell application "Finder"
if not (exists process "Mail") then tell application "Mail" to launch
end tell
tell application "Mail"
set my currentMailItem to {}
#
set my mailBoxProcessName to "* items to store"
try
if not (exists mailbox "* items to store") then make new mailbox with properties {name:"* items to store"}
end try
set tempMail to every message of mailbox "* items to shift"
if (count of tempMail) > 0 then
set theTempIDList to {}
repeat with eachmessage in reverse of tempMail
set end of theTempIDList to message id of eachmessage
set the mailbox of eachmessage to mailbox "* items to store"
end repeat
repeat with theTempID in theTempIDList
repeat with y from 1 to 11
try
if ((exists (some message whose message id is theTempID)) of mailbox "* items to shift") then
delete ((some message whose message id is theTempID) of mailbox "* items to shift")
else
exit repeat
end if
on error
exit repeat
end try
if y = 11 then
tell application "Finder"
tell application "Mail" to quit saving no
set x to 0
repeat
if not (exists process "Mail") then exit repeat
set x to x + 1
tell current application to delay 0.1
if x ≥ 40 then exit repeat
end repeat
if x ≥ 40 then
set The_app to "Mail"
try
tell application "System Events" to set pid to the unix id of process The_app as Unicode text
do shell script "kill " & pid
end try
end if
tell current application to delay 0.2
tell application "Mail" to launch
end tell
end if
end repeat
end repeat
end if


 _______________________________________________
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

  • Prev by Date: Re: New Office for Mac Beta and Applescript
  • Next by Date: Can I add text to the Administrator setting of a shell script?
  • Previous by thread: Re: New Office for Mac Beta and Applescript
  • Next by thread: Can I add text to the Administrator setting of a shell script?
  • Index(es):
    • Date
    • Thread