Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Speak Sender Name Only AppleScript in Mail No Longer Working In Mountain Lion

Hi all, the title pretty much says it all.

I have a very simple AppleScript that I use as a rule in Apple Mail everytime new email comes in.


This AppleScript will speak only the sender's name. That's all I want it to say.

I there are two emails, it will say, "Mail From John Smith" followed closely by "Mail From Johnny Appletree", etc.


This works great in Lion as a Mail rule.


I have properly placed this AppleScript in the correct path for Mail scripts.

It's located in:


(user name)/Library/Application Scripts/com.apple.mail


I've popped in the sample script provided by Apple into this same path that speaks the total number of selected emails, the name and the subject, etc. That works fine, so I'm positive the path is correct. But that script says a bunch of items I don't need. I just need a simple script and I'm guessing somehow the conversion from Lion to Mountain Lion doesn't work for some reason with this script.


Anyone know how to modify this supposedly simple script to make it work in Mountain Lion?

Any help is most appreciated, thanks! 🙂



Here is the script I had been using in Lion as a Mail rule without any issues before Mountain Lion:



on perform_mail_action(info)

-- see if iTunes is playing

set itunes_playing to false

tell application "System Events"

if (get name of every process) does not contain "iTunes" then

set itunes_playing to false

else

tell application "iTunes"

if player state is playing then set itunes_playing to true

end tell

end if

end tell

-- pause iTunes if needed


if itunes_playing is true then tell application "iTunes" to pause



tell application "Mail"


set the_messages to |SelectedMessages| of info


repeat with a_message in the_messages


set the_sender to extract name fromsender of a_message


if (junk mail status of a_message) is not true then


say "Mail from " & the_sender


end if


end repeat


end tell



-- resume iTunes if it was playing before


if itunes_playing is true then tell application "iTunes" to play


end perform_mail_action

Mac Pro (Mid 2010), Mac OS X (10.7.2)

Posted on Oct 19, 2012 2:11 AM

Reply
9 replies

Oct 19, 2012 6:46 AM in response to Mike Mcgee

Hi,


This script should work, try it :


using terms from application "Mail"
      on perform mail action with messages theselectedMessages


            tell application "iTunes" -- this doesn launch Tunes if iTunes is not running
                  set itunes_playing to running and player state is playing -- see if iTunes is playing 
                  if itunes_playing then pause -- pause iTunes if needed
            end tell

            tell application "Mail"
                  repeat with a_message in theselectedMessages
                        set the_sender to extract name from sender of a_message
                        if (junk mail status of a_message) is not true then
                              tell me to say "Mail from " & the_sender
                        end if
                  end repeat
            end tell

            -- resume iTunes if it was playing before
            if itunes_playing then tell application "iTunes" to play

      end perform mail action with messages
end using terms from

Oct 19, 2012 7:14 AM in response to Jacques Rioux

Jacques,


I really appreciate your reply, but that script didn't do anything.


The only two scripts I placed in the proper folder are the one from Apple that Speaks the Sender and subject (and message number, etc) and the script you posted above. I know they're both in the right path, because they are choices in Mail.


When I select the Apple-made script, that script works.

But when I select your script, nothing happens.


User uploaded file

Oct 19, 2012 8:19 AM in response to Jacques Rioux

Already tried that.

When I attempt to remove the parts I don't need, the script doesn't work anymore.


Again, I'm not a pro with AppleScript, but I've literally spent a few hours testing out different scripts trying to get this work, and finally posted here. I had to give up because it just didn't work.


Not sure why the AppleScript you provided didn't work.

Wasn't a syntax error or anything. It just did nothing as a mail rule.

Speak Sender Name Only AppleScript in Mail No Longer Working In Mountain Lion

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.