The following script works for all types of accounts (IMAP, POP, Exchange 2007, Exchange IMAP) in Mail app without any errors
tell account "accountName" to make new mailbox with properties {name:"Mailbox1"}
However, for Exchange 2007 account, the mailbox is not syncronized with the exchange server, so the messages moved there (and the mailbox itself!) do not appear in other email clients - basically exchange server did not see that mailbox. (by the way, messages moved to that folder from the application UI, are visible, while messages moved using script, are not visible - only message counter is increased)
if I create it from menu, Mailbox->New Mailbox, Mail application itself, has no issues with the mailbox, but mailbox, created using script is not syncronized properly.
Is there a way to make this work (maybe, specifying extra property) or any other way?
except maybe ui automation is not an option for me.
Reviving this old thread as I’m looking to do the same thing — create a Mailbox in an M365 account using scripting. But so far I’ve hit this brick wall when trying to do it with Mail.app (and different but similar walls when trying to script MailMate or Outlook).
tell application "Microsoft Outlook" --Outlook version 16.78.2 (scriptable)
tell exchange account 1
set newOutlookFolder to make new mail folder at end
end tell
end tell
Tags and top posting corrected by NG. (See Markdown reference here.)
Are you sure it’s a scriptable Outlook version and an actual Exchange account? (If so, I don’t understand why “Exchange account 1” wouldn’t be valid.) You could try referring to it by name as opposed to “exchange account 1”.
This works for me.
In Outlook scripting, mailboxes are called “mail folders”
This will only work if Outlook is not in “New Outlook” mode.
Also you didn’t mention what version of Outlook you were using?
tell application "Microsoft Outlook"
set myAccounts to exchange accounts
set myAccount to item 1 of myAccounts
tell myAccount
set mailFolderNames to name of mail folders
if "Mailbox1" is not in mailFolderNames then
make new mail folder with properties {name:"Mailbox1"}
end if
end tell
end tell