Automatically replying to email

I am trying to amend the script David shared in the latest MacPowerUsers to automatically insert Hi and the persons name when replying to an email in Apple Mail. I want to run it from Keyboard Maestro instead of TextExpander. I can’t get it to work though. Is someone able to assist?

I’ve amended the Script to be:

tell application "System Events" tell process "Mail" tell text field "To:" of window 1 if UI element 1 exists then set theToRecipient to (value of UI element 1) if ((count words of theToRecipient) is greater than 0) and (theToRecipient does not contain ",") then return word 1 of theToRecipient tell application "Keyboard Maestro Engine" try set value of variable "Result" to word 1 end try end tell else if ((count words of theToRecipient) is greater than 0) and (theToRecipient contains ",") then return word 2 of theToRecipient tell application "Keyboard Maestro Engine" try set value of variable "Result" to word 2 end try end tell end if end if end tell end tell end tell

The original unmodified AppleScript works fine for me if I set it to save the results to a variable:

1 Like

Thanks. That works for me. Appreciate the help.

1 Like