• 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
I want to delete 'Mail' mailboxes.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I want to delete 'Mail' mailboxes.


  • Subject: I want to delete 'Mail' mailboxes.
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 9 May 2017 21:48:49 +1000

G’day scripters

Some days ago I posted about Importing mailboxes, which Yvan was kind enough to respond to, and I discovered that the ‘import’ command only worked on 1 layer deep mailboxes.

I now want some way of automatically removing what can be a lengthy list of imports mailboxes, but while delete message works, delete mailbox fails, even when I delete all the contained messages.

The mailboxes concerned are on the ‘On My Mac’ account, which reads as ‘missing value’ when trying to get the account.

I’ve tried just deleteing multi-level mailboxes, mailboxes with and without messages,  etc, but the ‘delete’ command just doesn’t seem to work. I’ve also tried moving to the ‘trash mailbox’, which fails.

Any guidance please?

Regards

Santa



tell application "Mail"
set boxList1 to every mailbox whose name starts with (("Import") as list)
say (count of boxList1)
set theDeleteError to false
set x to 0
repeat with eachMailBox in boxList1
set internalList to mailboxes of eachMailBox as list
repeat with internalMailBoxes in internalList
set internalList to messages of internalMailBoxes as list
say (count of internalList)
repeat with eachmessage in internalList
try
delete eachmessage
end try
end repeat
set internalList to messages of internalMailBoxes as list
say (count of internalList) — zero
#tell application "System Events" to display dialog (name of internalMailBoxes) as text
do shell script ("sleep 1")
#delete mailbox ((name of internalMailBoxes) as rich text) of mailbox ((name of eachMailBox) as rich text)
delete internalMailBoxes  —< fails
end repeat
delete eachMailBox
end repeat
end tell

 _______________________________________________
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: I want to delete 'Mail' mailboxes.
      • From: Brian Christmas <email@hidden>
  • Prev by Date: Getting around Log's limitations
  • Next by Date: sub-routines' error
  • Previous by thread: Getting around Log's limitations
  • Next by thread: Re: I want to delete 'Mail' mailboxes.
  • Index(es):
    • Date
    • Thread