I'm having some problems. Googling them I found this:
I'm having almost identical problems.
tell application "Mail" to make new account ...
...appears to succeed from the perspective of the script or Script Editor - if I query Mail with:
get every imap account
the new account is returned there - however, it doesn't appear in Mail's Preferences under the Accounts tab, it doesn't appear in Internet Accounts, and if I restart my Mac and query Mail again for every imap account, it is no longer returned.
The other issue I'm having (closely related): I'm able to change some of the properties of an account, but having issues with two of them. (for these code snippets, theAccount has been set to a valid imap account in Mail):
1 enabled property
tell theAccount to set enabled to true
get enabled of theAccount
...gives me "Apple event failed" error. If I substitute any other readable imap account property in place of "enabled" (eg. name, user name, port, uses ssl, etc.) it returns the appropriate value. But anything I try to do with that property (get it or set it) gives me that error. Huh...?? Why that one and only that one?
2 authentication property:
tell theAccount to set authenticaion to password
...gives "Can’t make password of account [...] into type constant". That value (password) is one of a number of constants in the dictionary for the Authentication enumeration. I'm confident I have the syntax correct (in principle) because if I substitute password in the above code with any of the other constants in that enumeration (kerberos 5, md5, none, etc.) it works fine. Only password gives that error.
Script Editor/AppleScript seems to believe I'm referring to the password property of theAccount, and that makes sense, so the question is how do I use that password enumeration constant? How do I tell Mail that I want to set theAccount's authentication property to that password enumeration constant (and not the password property)?
Anyone have any idea what I am, (or Apple is -- bug?), doing wrong here?
Thanks in advance!
UPDATE the next day:
In hindsight, I should have posted this as two separate questions.
@CJK's answer solves the second one. His/her answer also suggests an answer to my first one as well (ie. it's just an Apple bug) though others may still have insight on that.
I'll mark @CJK's answer as correct on this post, but if anyone else has any answers to the first issue, please comment. I'll post that issue as a separate post/question, you can then answer there and I'll mark that up and as correct on that post.