Getting old Mail scripts to run in Mail 2.0

I just upgraded to Tiger (yeah, I know, I know…) and immediately found that Mail’s script menu no longer exists. I found the new “Applications” folder in the scripts folder and got the Mail scripts folder created and all was well…almost.

I found right away that all my scripts that are of the form:

using terms from application "Mail"
	on perform mail action with messages messageList
(*do some stuff*)
	end perform mail action with messages
end using terms from

no longer worked. After searching here and on Apple’s lists, I found that lots of people were complaining that “Mail’s scripting is broken.” After looking closer at Apple’s own scripts (which still worked from the system-wide script menu), I realized that Apple’s scripts had something mine didn’t. I thought I’d share this with everyone, since it has been such a big issue for a lot of people.

What Apple’s had that mine didn’t was this (in addition to the above code).

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

Hope this helps someone else!