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
|