cannot delete Mail mailboxes

Using MacOs Sierra, in Mail, I am trying to delete a mailbox, I am always getting the AppleEvent Handler Error 10000, no matter which mailbox, full or empty, local, or IMAP/POP.

Tell application “Mail”
delete mailbox “complaints” from account “ACME LLC”
end tell

This is not an issue with file permissions because I can rename a mailbox without problem.

FYI: I have reported several Sierra Mail / AppleScript issues to Apple, including your problem. Hopefully they are being addressed and will be fixed soon.

Still not fixed in the last update.

Can anyone with a beta of High Sierra confirm is this bug has been fixed or not?

No change with High Sierra.

Have you ever tried to get properties of every mailbox ?
If you do that you will see that the property account of every mailbox is set to missing value.
At this time we must identify accounts by their id.

tell application "Mail"
	properties of mailbox "aaa"
	--> {account:missing value, name:"aaa", container:account id "30ACBF46-881C-40AC-B33B-500D53832270" of application "Mail", class:container, unread count:0}
	properties of every mailbox whose name is "douteux"
	--> {{account:missing value, name:"douteux", container:mailbox "aaa" of application "Mail", class:container, unread count:0}}
	properties of mailbox "Batiactu."
	--> {account:missing value, name:"Batiactu.", container:account id "30ACBF46-881C-40AC-B33B-500D53832270" of application "Mail", class:container, unread count:0}
end tell

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) jeudi 22 juin 2017 12:05:48

I fail to see the relevance to this issue. Enlight me please.

true, but that does not prevent me to successfully execute :

tell application “Mail”
count messages of mailbox “brother” of account “zantafio”
end tell

furthermore referencing the mailbox using account ID, I am still unable to delete the mailbox.

tell application “Mail”
delete mailbox “brother” of first item of (accounts whose id is “94A311A3-88DD-4A52-B6F6-00223E540025”)
end tell

Result:
error “Mail got an error: AppleEvent handler failed.” number -10000