• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Running Scripts from Mail Rules
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running Scripts from Mail Rules


  • Subject: Re: Running Scripts from Mail Rules
  • From: Steve Bird <email@hidden>
  • Date: Sat, 28 Oct 2017 09:45:18 -0400

OK, that solved it.  I had an inactive IMAP account with the same email address
as my active POP account. Deleting the inactive one fixed the issue.
Even though I wasn’t directly dealing with accounts or mailboxes, the script
would get confused.

LESSON LEARNED:  If you don’t tell your users what the error is, then your
users don’t necessarily know what the error is.
Maybe I should send that tip to Apple, eh?
It’s wrong to just fail and not report any error.

For the record, here is the complete and working script:

using terms from application "Mail"
        on perform mail action with messages Msgs for rule theRule
                repeat with M in Msgs
                        try
                                if read status of M then
                                        -- say "This message has already been
read."
                                else --only speak for unread msgs
                                        set SndrName to extract name from
sender of M
                                        say "You have mail from " & SndrName
                                end if
                        on error errMsg
                                display dialog (errMsg)
                        end try
                end repeat
        end perform mail action with messages
end using terms from

I apply the same rule to sent messages, so that they get moved to the correct
storage mailbox (by the rule, not this script).
This script doesn’t announce that, because it looks at the “read status”.

I do this so that even if I am in the next room, I can tell who a mail is from
and react accordingly.

Thanks to Alex Luttgen in particular, and everyone else in general, for
spending a few brain cells on 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

  • Prev by Date: Re: Running Scripts from Mail Rules
  • Next by Date: Re: Running Scripts from Mail Rules
  • Previous by thread: Re: Running Scripts from Mail Rules
  • Next by thread: Seeing the state of an application with Script Editor?
  • Index(es):
    • Date
    • Thread