I am trying to make a script for Speech Recognition that checks for new mail and if there is new mail, read the names of the senders. The only scripts I can find need to be used in conjunction with Rules within mail. I have pieced together what scripts I can. It runs okay but it just does not repeat anything. Since I am still new to Applescript, I dont know what I am doing wrong and I am asking you guys for help.
set mailAccounts to {"Account1", "Account2", "Account"}
tell application "Mail"
check for new mail
set theMessages to messages of mailAccounts
repeat with eachMessage in theMessages
tell application "Mail" to set theSender to extract name from sender of theMessages
say "you got mail from " & theSender
end repeat
end tell
set mailAccounts to {"Account1", "Account2", "Account"}
tell application "Mail"
check for new mail
repeat with oneAccount in mailAccounts
set theMessages to (messages of account oneAccount whose read ststus is false)
repeat with eachMessage in theMessages
set theSender to extract name from sender of eachMessage
say "you got mail from " & theSender
end repeat
end repeat
end tell
Note: Within a mail rule the script could not work because of the say command
set mailAccounts to {"Account1", "Account2", "Account"}
tell application "Mail"
check for new mail
repeat with oneAccount in mailAccounts
set theMessages to (messages of mailbox "INBOX" of account oneAccount whose read status is false)
repeat with eachMessage in theMessages
set theSender to extract name from sender of eachMessage
say "you got mail from " & theSender
end repeat
end repeat
end tell