Set clipboard directly from Applescript menu for Mail.app

I hope someone can help with this one. i must be missing something. What I would lke to do is to copy the subject from an email that I have selected and then use this to go and run a Filemaker script with this clipboard informatin. I have got it working if I set a rule up to run the script like this:

using terms from application “Mail”
on perform mail action with messages theMessages for rule quotefinder
tell application “Mail”
activate
repeat with eachMessage in theMessages
set theContent to subject of eachMessage
set the clipboard to theContent as text
tell application “FileMaker Pro”

				do something
			end tell
		end repeat
	end tell
end perform mail action with messages

end using terms from

The problem comes in that I don’t want to have a rule set up as it would interrupt what I was doing and would like to just run the script from the Mail Applescript menu so thaty I can run it when i choose. However because the script has the line:
on perform mail action with messages theMessages for rule quotefinder
it doesn’t do anything if I try to run it manually from this menu. I have tried removing this line and the associated
end perform mail action with messages
line but this doesn’t seem to help as theMessages is no longer defined.

I’m sure it must be something simple way to fix this but I just can’t quite get it. Any ideas?

Thanks

Rufus

Hi Rufus,

try this, it processes the selected messages

tell application "Mail"
	activate
	set theMessages to selection
	repeat with eachMessage in theMessages
		set theContent to subject of eachMessage
		set the clipboard to theContent as text
		tell application "FileMaker Pro"
			-- do something
		end tell
	end repeat
end tell

Hi Stefan

Thanks for that. Yes it works perfectly. Simple when you know how i guess. I think that i must have tried every which way but that.

Thanks again

Rufus