• 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 won't launch Applescript as part of a rule
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail won't launch Applescript as part of a rule


  • Subject: Re: Mail won't launch Applescript as part of a rule
  • From: cricket <email@hidden>
  • Date: Wed, 19 Mar 2003 15:31:32 -0800

Rule based scripts use a specific handler, so anything in an 'on run' handler or in the main body of a script won't run. The reason for this is that a rule can pass in a Rule object and a message object, allowing you to perform custom logic within the script on the message that triggered the rule.

Example:

on perform_mail_action(info)
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
set theRule to |Rule| of info
repeat with eachMessage in selectedMessages
set theSubject to subject of eachMessage
set theRuleName to name of theRule
set theText to "The rule named '" & theRuleName & "' matched this
message:" & return & return & "Subject: " & theSubject
display dialog theText
end repeat
end tell
end perform_mail_action

In the example, 'info' is an Applescript record with two keys:
|SelectedMessages| and |Rule|. |SelectedMessages| is a list of message
objects that match the conditions for the rule. As messages are fetched
and evaluated in batches, this list may contain more than one message,
so be sure to take that into account. |Rule| is the rule object that
triggered the script action.

- cricket

On Tuesday, March 18, 2003, at 10:16 PM, Sunil Vyas wrote:

Does anyone know why Mail won't launch the following compiled script as
a rule?
It runs fine when I hit run in Script Editor:
tell application "Mail"
set ListOfNewMessages to {}
set ListOfMessages to every message of in mailbox
repeat with i in ListOfMessages
if (is read of i is false) and (is junk mail of i is false) then
set SenderName to (sender of i)
set ListOfNewMessages to ListOfNewMessages & SenderName
end if

end repeat
try
if listofnewmail !A {} then
say "Sunil, you have new mail from " & ListOfNewMessages
end if
end try
end tell

Thanks, Sunil
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

----->
Software Entomologist  Mail for Mac OS X
http://www.apple.com/macosx/jaguar/mail.html
---------->
In the end, twenty years were wrapped up in a wordless montage, and even the on-set rain machine seemed to know it was over.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: 
 >Mail won't launch Applescript as part of a rule (From: Sunil Vyas <email@hidden>)

  • Prev by Date: Re: Help..
  • Next by Date: Re: Scripting Quark on B&W G3 hard disk problems
  • Previous by thread: Mail won't launch Applescript as part of a rule
  • Next by thread: Help..
  • Index(es):
    • Date
    • Thread