AppleScript works for everything except Exchange server emails
Here is the script:
using terms from application "Mail"
set theRuleName to name of theRule
on perform mail action with messagestheMessagesfor ruletheRule
tell application "Mail"
repeat with eachMessage in theMessages
set theSender to extract name from (sender of eachMessage)
say "Mail from " & theSender using "Alex"
end repeat
end tell
end perform mail action with messages
end using terms from
It is called from a Mail rule. Here is the rule:
It works for every incoming message except for those that originate from an Exchange account.
Here is the interesting part: If I manually "apply rules" by selecting the message and using Option ⌘ L then it speaks the name perfectly. It is only when the mail arrives (by checking for new mail, for instance) that the script does not appear to do anything.
More interesting: The email does get its background color set to Blue. So as far as I can tell, the Rule is being executed, but the script isn't.
Here is the Rule for everything else:
(speakname5 is identical to speakname6 just without the voice "Alex" - here it is anyway)
using terms from application "Mail"
set theRuleName to name of theRule
on perform mail action with messagestheMessagesfor ruletheRule
tell application "Mail"
repeat with eachMessage in theMessages
set theSender to extract name from (sender of eachMessage)
say "Mail from " & theSender
end repeat
end tell
end perform mail action with messages
end using terms from
If I try to simply use the same Rule for everything it still does not work for the Exchange email account. That is the reason for two separate scripts - it was a troubleshooting attempt.
Why does it only work when manually "applying Rules"?
Is there anything else I can include in the speakname6 script to indicate that it is actually being called?
Here are all my Rules, so that their order is known:
MacBooks iMacs iPods AirPorts-OTHER, OS X Mountain Lion, 27 years Apple!