0

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?

4
  • Well I can propose something to make you able to select the newest message that comes to your inbox. Are you interested and does it answer your question? I want to be sure before posting.
    – Thinkr
    Commented Mar 15, 2023 at 21:28
  • I am interested in this. However, I am really trying to understand why the Rule script to announce a new email works when it is by itself and why it doesn’t work if there is another action added to it. And possibly if there is a workaround. Commented Mar 15, 2023 at 22:07
  • Try replacing the second line of your code with 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?
    – Thinkr
    Commented Mar 16, 2023 at 6:29
  • Nope. That didn't work. The script I posted works as long as it is the only action in the Rule, but adding a Move Message action makes it ignore the AppleScript. I even tried creating two separate Rules, one that says the sender name (with the above script) and the second one that moves it. I placed the announcement rule before the move rule and it still ignored the AppleScript. Very confusing. Commented Mar 16, 2023 at 22:35

0

You must log in to answer this question.

Browse other questions tagged .