Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the ' Adapted, not wrote...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Adapted, not wrote...
Authored by: mhv on Apr 25, '04 05:31:10PM
Ahem, I don't want to spoil the fun, but although you have done yourself the work of making the script do what you say it intends to do, you should still have mentionned, for the sake of honesty, and Apple's licensing (see below) that you took a sample Applescript that comes with Panther, and adapted it here and there to add the functions. You didn't even bother changing the variables' name. See:

/Library/Scripts/Mail Scripts/Script Menu/Speak Sender and Subject___ctl-s.scpt


(*
Speak Sender and Subject

Copyright © 2003 Apple Computer, Inc.

You may incorporate this Apple sample code into your program(s) without
restriction.  This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours.  You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes.  If you're going to redistribute the code, we require
that you make it clear that the code was descended from Apple sample
code, but that you've made changes.
*)

(*
This script demonstrates how to write a script that can be executed
directly from the Scripts menu in Mail. It acts on the selected messages,
which are passed in to the 'perform mail action with messages' handler.

This script also demonstrates the syntax for adding a keyboard shortcut to
a Scripts menu item. You can do this by suffixing the name of the script with
three underscore characters, then the keyboard shortcut. For example:

MyScript___ctl-shift-Y
MyScript___opt-cmd-Z
*)

using terms from application "Mail"
	on perform mail action with messages selectedMsgs
		-- See Mail's AppleScript dictionary for the full documentation on the
		-- 'perform mail action with messages' handler.
		set logString to "" & return
		tell application "Mail"
			set selCount to (count of selectedMsgs)
			if selCount is equal to 0 then
				set logString to logString & "There are no selected messages."
			else if selCount is equal to 1 then
				set logString to logString & "There is " & selCount & " selected message."
			else if selCount > 1 then
				set logString to logString & "There are " & selCount & " selected messages."
			end if
			repeat with counter from 1 to selCount
				set msg to item counter of selectedMsgs
				set theSubject to subject of msg
				set theSender to sender of msg
				set theSender to extract name from theSender
				set logString to (logString & tab & "Message " & counter as string) & " from: " & theSender & ", subject: " & theSubject & ".  "
			end repeat
		end tell
		if length of logString > 0 then
			say logString
		end if
	end perform mail action with messages
end using terms from

-- If run as an ordinary script, instead of directly from the Scripts
-- menu, it will call the default handler instead.
using terms from application "Mail"
	on run
		tell application "Mail" to set sel to selection
		tell me to perform mail action with messages (sel)
	end run
end using terms from


[ Reply to This | # ]
Adapted, not wrote...
Authored by: groundspeed on Apr 25, '04 07:01:18PM

Tried this script but it didn't work as posted,

1) I had to put underscores for "perform_mail_action_with_messages(sel)"

2) script editor doesn't understand "extract name" with or without underscores. It isn't in Mail's dictionary. Do I need a newer versiion of mail? I have 1.2.5 (v553).

3) I set a rule in Mail set to every message and to run the script. I tried pointing to other scripts but it won't run any when new mail comes in. Other rules work fine.

What am I doing wrong?

---
When I die, I want to go peacefully in my sleep, like my Grandfather, not screaming in terror like his passengers.



[ Reply to This | # ]