I found script parts to create a mailbox in apple mail via apple script on a MacBook on Monterey:
tell application "Mail"
activate
make new mailbox with properties {name:"Parent Mailbox1/Child Mailbox1/"}
make new mailbox with properties {name:"Parent Mailbox2/Child Mailbox2/"}
end tell
While execution I get a --> missing value output but the mailbox structure is created locally:
Parent Mailbox1/Child Mailbox1
Parent Mailbox2/Child Mailbox2
If I now want to do this with an iCloud account directly:
tell application "Mail"
activate
tell account "iCloud"
make new mailbox with properties {name:"Parent Mailbox1/Child Mailbox1/"}
make new mailbox with properties {name:"Parent Mailbox2/Child Mailbox2/"}
end tell
end tell
Apple Mail seems to be busy quite a moment by typical busy cursor indication, the value missing output is the same but no mailbox is created in the account. I even tried to enumerate the account id and used it instead and tried at the end of mailbox, but after the busy time around 6-8 seconds per mailbox, no mailbox is created.
I have no clue where to find some debuging information on why mails seems busy but does not create the mailboxes. I thought about extending it with a try catch and error output, but maybe somebody already knows the reason for apple mail behaviour in this area?
Kind regards