Running Scripts from Mail Rules
Running Scripts from Mail Rules
- Subject: Running Scripts from Mail Rules
- From: Steve Bird <email@hidden>
- Date: Thu, 26 Oct 2017 15:29:03 -0400
My problem with AppleScript is that I don’t use it enough to be really familiar
with it’s quirks, and it’s such a PITA when I DO use it that i don’t want to
use it much.
But this script has been broken for a couple of years (after working for
several), and I really need it to work again.
i’m trying to run a script from a MAIL rule. I want to announce (using “say”)
who the message is from.
This is so that I can hear if a message comes in from somebody in particular,
without announcing all the list messages and other stuff.
It worked fine until system 10.9 (I think it was). At that point, something
changed. I found the new terminology ( “on perform mail action with messages”)
and fixed it, and it worked fine for a while, but it quit working with another
sys update. I tried and tried but it hasn’t worked.
I’m trying again. I boiled it down to this test script.
The problem looks like it can’t do anything with the message. If doesn’t
cause an error, it doesn’t return anything, it just quits. No message, no
crash, just quits.
It will say the “Got message” part. Every time. But it will always fail to say
the “Got sender” part. Every time.
I can change “sender” to “subject”, or “Content”, or “id”, any other term in
the Mail dictionary, and the same thing happens.
The latest googling I’ve seen says this should be correct, but it just doesn’t
work.
What am I missing? Why doesn’t it report an error, at least?
I’m on Sys 10.11.6 with Mail 9.3
using terms from application "Mail"
on perform mail action with messages (Msgs)
set N to count of Msgs
say "Messages: " & N
repeat with i from 1 to N
say ("Start " & i)
try
set M to item i of Msgs
say ("Got message")
set Nm to (sender of M)
say ("Got sender")
set S to (extract name from (sender of M) as
rich text)
say ("You have new mail from " & S)
on error
display dialog (errMsg as rich text)
end try
say ("end " & i)
end repeat
end perform mail action with messages
end using terms from
P.S. I know there are better ways to loop thru an array, but I’m chasing bugs
here and tried this.
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com <http://www.culverson.com/> (toll free)
1-877-676-8175
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden