MacMegasite Archive
   


To reduce the database size and server load, all articles from 2004 or earlier are archived here.


Return to MacMegasite



       

Tue, 24 Dec 2002

Merry Christmas from MacMegasite

The staff of MacMegasite would like to wish all of our readers a merry Christmas. Updates will probably be infrequent for the next week.

[] permanent link

New Mail feature in 10.2.3 - Run AppleScript

The Mac OS X 10.2.3 update adds a great new feature to Mail.app: the ability to run an AppleScript as a rule action.

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).



[from the AppleScript Users mailing list]

[] permanent link