OT - Running AppleScript from a Mail Rule

Michel Angelo michel_angelo at me.com
Thu Aug 13 05:40:33 EDT 2020


Hello Sean, on 12 aout 2020 at 19:49, Sean Lavigne <sean at houselavigne.us> wrote :

> I’m having trouble triggering an AppleScript from within an Apple Mail rule.

I did not read the details of what reliability you expect from this action (and James was quite clear on it). I found a use for using Mail to issue an applescript instruction to xtension, and the failure rate is about one to two days a month. Given that you can move Mail around, it will still receive any message, my suggestions would be:
Use the same mac, the same account for Mail and xTension (don’t ty to separate them)
Create a dedicated email account for these messages in such a way that tehey will only land on this Mail app
Beware of imap (rather choose pop3), beware of mail filter, which can be on the server, on the mail application or as an aside
Get organised to receive the triggering mail messages 2 times: The primary one will be on the Pop account of the dedicated mail account on the dedicated Mail client, the second will be addressed to your account and be also received by the xTension’s Mail client. 
The script I use is as simple as it can be:
It is a script located on the same account as xTension, on: Library > Application scripts > com.apple.mail
the mail action filters the triggering message (I use the headers, the filter accepts each one of the two messages which are issued) and issues a script that it finds on the above directory
The script simply calls a global script of wTension
tell application "XTension"
	execute script "sXTensionPowerDownD2"
end tell
For me the global script calls a handler in a bigger script
execute script "Sauvegardes" handler "hPowerDown" parameters {"D2 »}
Which handler is in charge of doing the heavy lifting. Here it turns off the power block of a backup disk (called D2 of laCie) after completion of the backup task and unmounting of the drive. My triggering mails are issued by carbonCopyCloner. 

You can do far more complex, but what will be the value added by increased layers of complexity ?

HTH

— 
Michel Angelo
<michel_angelo at me.com>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20200813/9143f6f4/attachment.html>


More information about the XTensionList mailing list