Reputation: 60
I have set up a rule that when a email comes in from a certain sender an Applescript gets triggered. I would like that the Applescript extracts contents from the mail that triggers the rule to be send to a PHP script that sends it as a webhook to a database. Everything works except for the the code won't run past 'on perform mail action with messages theMessages for rule theRule', it just skips that block of code and will never get to the repeat block.
What am I doing wrong?
If you need any more info I would be happy to provide.
Thanks in advance!
set d_recd to missing value
set theText to missing value
set theSender to missing value
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with theMessage in theMessages
set theDate to date recieved of theMessage
set theText to content of theMessage
set theSender to sender of theMessage
end repeat
end perform mail action with messages
end using terms from
do shell script ("php -q /Users/kaartendrukkerijmacmini/Dropbox/Technische_ontwikkeling/PHP_Webhook_approval_post.ctp " & d_recd & space & theText & space & theSender)
Upvotes: 1
Views: 185
Reputation: 285270
The do shell script
line must be inside the handler. And you have to quote all parameters and coerce theDate
to text.
Finally there is a typo: It's date received
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with theMessage in theMessages
set theDate to date received of theMessage
set theText to content of theMessage
set theSender to sender of theMessage
do shell script "php -q /Users/kaartendrukkerijmacmini/Dropbox/Technische_ontwikkeling/PHP_Webhook_approval_post.ctp " & quoted form of (theDate as text) & space & quoted form of theText & space & quoted form of theSender
end repeat
end perform mail action with messages
end using terms from
If the handler is not called at all the issue is somewhere else.
Upvotes: 1