• 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 a script from Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running a script from Mail.app


  • Subject: Re: Running a script from Mail.app
  • From: cricket <email@hidden>
  • Date: Thu, 13 Mar 2003 12:03:40 -0800

On Wednesday, March 12, 2003, at 4:17 PM, Mike wrote:

I still am unable to run an external script using rules in Mail.app. Can
anyone confirm that mail.app will run an external scrip upon receiving a
rule trigger?

My scripts run appropriately when launched as an application or run from
within script editor however nothing happens when I set the script to run as
an action within a rule definition.

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. (Note: We hope to have a Scripts menu in
Mail for the next major release of Mac OS X, which will extend the
perform_mail_action handler to also act on selected messages).

- cricket

----->
Software Entomologist  Mail for Mac OS X
http://www.apple.com/macosx/jaguar/mail.html
---------->
A carnivorous plant will come to visit you in the night.
_______________________________________________
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: 
 >Running a script from Mail.app (From: Mike <email@hidden>)

  • Prev by Date: Re: scripting mail to select mailboxes
  • Next by Date: Re: reboot into OS 9
  • Previous by thread: Running a script from Mail.app
  • Next by thread: Re: Running a script from Mail.app
  • Index(es):
    • Date
    • Thread