Just getting started, State of the AppleScript and MacOS, I'm trying Apple Mail scripting?

Was looking to create some AppleScripts that worked with Mail, and can’t seem to get things working. I have MacOS Sonoma, just installed Script Debugger and see the warning about “Full Disk Access” but Script Debugger isn’t listed in System Settings. I tried some simple scripts to tell application “Mail”, but just getting “Can’t get…” errors. The only thing that seems to work is getting a value like version = “16.0”.
More generally I’m wondering about support by Apple, and the generate state of the tools like this. Would love to use and see what can be done!
Any comments about what works, what doesn’t in the latest versions of MacOS?

AppleScript is still supported across many macOS applications, and is not going anywhere anytime soon, since the APIs it relies upon are built into the operating system at a low level. That said, there’s a general trend of decreasing scriptability across applications (which must write explicit support for AppleScript).

Apple hasn’t made any significant updates to the language itself in half a decade. It seems to be in minimal-maintenance mode, and is still missing many features of other popular high-level languages like python.

Don’t be misled by the easy-appearing English-like syntax of AppleScript; in my opinion, AppleScript is one of the most difficult languages to learn how to write. There are too many hidden pitfalls. The syntax is complicated, convoluted, and many important things are “swept under the rug”. The tooling is lacking, and there is a dearth of documentation.

Beyond the language itself, part of the challenge of writing AppleScript is how differently and opaquely scriptability is implemented by each application. Even if you know the language itself, learning how to script a new application can be very challenging.

So why is AppleScript still around? It’s still the most powerful automation language available on the platform. For many tasks, nothing else works as reliably or as easily. It can be readily integrated with shell scripts, other scripting languages, Automator workflows, and system frameworks (through ASObjC, which is extremely powerful) as needed. It’s the only language with native support for interacting with macOS applications through the open scripting architecture, except for JavaScript for automation (which still requires you to understand how AppleScript works).

Here’s a cut-down example version of a short Mail script (to make an outgoing message) that I wrote last week. Despite knowing the AppleScript language very well, I haven’t had to script Apple Mail much before. Most of the time was spent in trial & error in trying to understand the scripting dictionary. That’s fairly typical of AppleScript (and why Script Debugger is such a time-saver).

tell application "Mail"
	set outgoing_message to make new outgoing message with properties {subject:"Report - " & short date string of (current date), content:"Email body."}
end tell

There was a bigger discussion on the future of AppleScript here last year, which may be of interest.

I wrote both ebooks in Japanese.

AppleScript The Latest Reference for v2.8 (PDF 1,008 pages)

AppleScript The Latest Reference for v2.8 English translation (1/4) in progress

Mail.app Scripting Book with AppleScript (PDF 396 pages)

This ebook is partly translated in English (Cover pages and titles).