• 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: Mail script puzzlement
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail script puzzlement


  • Subject: Re: Mail script puzzlement
  • From: Christopher Stone <email@hidden>
  • Date: Tue, 21 Jun 2016 17:27:27 -0500

On Jun 21, 2016, at 13:21, Jeremy Roussak <email@hidden> wrote:
The script is below. The issue is that when an email is received which runs the rule, the single message passed to the script isn’t the one that triggered the rule. Am I doing something wrong?


Hey Jeremy,

It would seem that Mail rules which execute AppleScripts are still very unreliable.

This works perfectly for me IF if manually run rules:

-------------------------------------------------------------------------------------------
using terms from application "Mail"
   on perform mail action with messages messageList for rule theRule
      try

         

         tell application "Mail"
            repeat with theMessage in messageList
               set msgSubject to theMessage's subject
               display notification "Mail Message" with title msgSubject subtitle ("Rule: " & name of theRule as Unicode text) sound name "Sosumi"
            end repeat
         end tell

         

      on error e number n
         set e to e & return & return & "Num: " & n
         if n ≠ -128 then
            errorMessage() of me
         end if
      end try
   end perform mail action with messages
end using terms from

on errorMessage()
   try
      tell application (path to frontmost application as text) to set ddButton to button returned of ¬
         (display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
            default button "OK" giving up after 30)
      if ddButton = "Copy Error Message" then set the clipboard to e
   end try
end errorMessage
-------------------------------------------------------------------------------------------

But it fails most of the time when rules are applied as message arrive.

Very disappointing.

--
Best Regards,
Chris

 _______________________________________________
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

References: 
 >Mail script puzzlement (From: Jeremy Roussak <email@hidden>)

  • Prev by Date: Re: en-dash, em-dash, and the like — wrong gist address
  • Next by Date: Re: Mail script puzzlement
  • Previous by thread: Mail script puzzlement
  • Next by thread: Re: Mail script puzzlement
  • Index(es):
    • Date
    • Thread