I am trying to create a simple AppleScript that I can use with rules to announce the incoming sender of a message. I want it to say their name and not their email address as well. This is what I have so far and it works if a message is selected.
tell application "Mail"
set theSender to sender of item 1 of (get selection)
set theName to word 1 of theSender & " " & word 2 of theSender
say "Incoming email from " & theName
end tell
This kind of works but doesn't seem to work with a rule that has more than one action. If I set the rule to only run the AppleScript and nothing else, it works. However if I add an action to move the message to a specific folder, it will move it but without saying the sender name. Any ideas what's going on or how I can fix this?
set theSender to sender of the first message of mailbox "xxx1" of account "xxx2"
. Replace the xxx1 by your inbox name and replace the xxx2 by the name of your service (e.x. "iCloud"). What does it do?