Re: Deleting messages in Trash - On My Mac
Re: Deleting messages in Trash - On My Mac
- Subject: Re: Deleting messages in Trash - On My Mac
- From: Axel Luttgens <email@hidden>
- Date: Thu, 15 Mar 2012 10:07:31 +0100
Le 15 mars 2012 à 01:55, email@hidden a écrit :
> Whenever I delete an e-mail from this list, it doesn't go to trash of the account that received it - it goes to the "Trash - On My Mac" account. Because of this, my mail rules for deleting e-mail don't apply those messages. So I'm looking for a way to delete the trashed mail that is in the "Trash - On My Mac" account, and only that account. I've tried many things I've found online but none of them work. Here's one example that failed:
>
> tell application "Mail"
> set theAccount to "Trash - On My Mac"
> delete every message in theAccount
> end tell
>
> Is there a way to do this?
Hello Marc,
The "On my Mac" account is some kind of artifact, and is certainly strangely handled in Mail's scripting model.
This one seems to do want you want:
tell application "Mail"
delete messages of mailbox "Deleted Messages"
end tell
That is, one is referring an application's mailbox, not a mailbox of a "true" account.
But this assumes that the name of that mailbox will always be "Deleted Messages". I wouldn't swear it. So, to play on a perhaps safer side:
tell application "Mail"
repeat with mbox in mailboxes of trash mailbox
if account of mbox is missing value then
delete messages of mbox
end if
end repeat
end tell
This relies on the fact that Mail's trash mailbox property allows to access all trashes; the one that doesn't belong on a "true" account is the On my Mac one.
HTH,
Axel
_______________________________________________
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