Re: running applescripts from Mail
Re: running applescripts from Mail
- Subject: Re: running applescripts from Mail
- From: cricket <email@hidden>
- Date: Wed, 12 Mar 2003 12:49:48 -0800
You can attach an ordinary Applescript as a rule action, or write a
script that uses the 'perform_mail_action' handler if you want to
access the messages that matched the rule or the rule object itself:
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
On Tuesday, March 11, 2003, at 11:11 PM, Mike wrote:
Are there any special conditions that apply to the OS X Mail program to
get it to run an applescript.
as an example,
I have a very simple test script
On run
Beep 2
Display dialog "A VERY IMPORTANT MESSAGE HAS ARRIVED buttons {"OK"}
default,
button "OK"
End run
I created a rule with the condition that "test" is in the subject line.
I set the action to run Applescript and navigated to the test script. I
also
set an action to color the text of the test message.
Mail colors the text upon receiving the test message so I know the rule
is
triggering but the applescript never runs. Am I overlooking something
or
the Run AppleScript not functional in mail?
_______________________________________________
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
---------->
If it wasn't for disappointment, I wouldn't have any appointments
_______________________________________________
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.