I’m struggling while getting the account type from a mail account in an ASOC app.
The following code returns the correct info in vanilla AppleScript, where in ASOC it doesn’t:
tell application "Mail"
return account type of account "My mail account"
end tell
In vanilla AppleScript this returns: POP or IMAP
In ASOC I get:
<NSAppleEventDescriptor: ‘etpo’> for a POP account and
<NSAppleEventDescriptor: ‘etim’> for a IMAP account
Is there a way to coerce this to the actual string values as vanilla AppleScript does?
're getting the same result – it’s just that the console shows AS classes as NSAppleEventDescriptors, which is what they become when they get passed to Cocoa.
And you get something similar for AppleScript if you run it outside a script editor. When you do it in a script editor, the editor loads the app’s dictionary and translates between terminology and underlying codes – outside a script editor, that doesn’t happen. (Yes, Xcode is a script editor of sorts, but the console is not a script log.)
That’s actually what I was using as a workaround before.
I figured it was a better approach to coerce the actual data returned from Mail.app instead of relaying on my own interpretation of it in an if statement. If something changes in Mail.app’s code in the future, the coercing is more likely going to stand, while my own interpretation of the returned data is probably going to fail without an update of my app.
Anyway, I’m going to look into it. Thanks for the valuable info and insights!
Actually, it’s likely to be exactly the other way around. The most common changes are terminology, so relying on attempts to coerce are doomed to failure.