Not authorized to send Apple events to Mail

I’m using the AppleScript that @MacSparky posted last year (?) a lot.
Suddenly it stopped working on my iMac, but still does work on my Macbook Pro.
Any clue what causes the message:‘Not authorized to send Apple events to Mail.’?
It runs through a TextExpander snippet which is synced between the 2 computers.

Any ideas are welcome.

Does the script still run okay from the native script editor? That could help narrow down if it is TextExpander that would need the permission.

Yes, it works in the native script editor.

Ok, so TextExpander specific, and likely that app isn’t asking for the permission.

I think when it does so, the Mail app should appear under the Preferences > Security & Privacy > Privacy > Automation > TextExpander settings. I just don’t know if TextExpander is set-up to prompt for this (I do use TextExpander, but not Mail.app).

At one point you could use a utility to push things in via the command line, but security restrictions have (rightly) locked that down. I don’t think there’s a way around that except to get Smile to add something in; though maybe some other way does exist that someone else can suggest?

You can of course reset the Apple Events permissions database via the command line.

tccutil reset AppleEvents

But if TextExpander doesn’t ask for permission, then you’re a few steps back as you’ll have to reauthorise everything. However if TextExpander does support asking for the permission, this is the right way to proceed.

As a workaround, I’m wondering if you could save your AppleScript, and then use a shell script in TextExpander to call it via osascript? I think that could put it into the realm of indirect access and so it wouldn’t be TextExpander asking for access, but your shell. Might be worth a try :man_shrugging:t2:

Thanks,

TextExpander seems to be authorized on my iMac…

Okay, might be worth trying the permissions reset then.

I did reset the Apple Events permissions database with the command you provided.
The result is the same. Still the error message in TextExpander. In the script editor it works. Textexapnader is not asking for authorization…

Sounds like that’s worth raising as a query with Smile’s support and showing both screenshots.

Did the workaround I suggested work?