pasting Filemaker field value into Mail.app To: field

I am completely new to Applescipt and cannot find how to do this simple task. I have a Filemaker dbase and want to be able to click a button that copies the email address from the EmailAddress field in Filemaker, and then open the Mail.app, create a new message, and paste the EmailAddress field contents into the new Mail message TO: field. I can get as far as creating the new Mail message, but I can’t seem to get the value of my Filemaker dbase field to paste into the TO: field.

Any help would be appreciated. Thanks in advance.

Here’s a simple example that uses the front FMP database. In line 2, you’ll need to change “emailAddressFieldName” to the name of your address field in the database.

tell application "FileMaker Pro"
	set emailAddress to cell "emailAddressFieldName" of current record
end tell

tell application "Mail"
	set nm to make new outgoing message
	tell nm
		set visible to true
		make new to recipient at end of to recipients with properties {address:emailAddress}
	end tell
end tell

I tried the script you suggested. I get an Object Not Found error in Filemaker (I am using the Filemaker Script Step “Perform Applescript”). Any other ideas that may work?
Thanks.

That script works on my setup (FMP 6.0v4 and OS X 10.2.3). Did you make the necessary change to the script (the name of the email address field)?

Yeah, my field name is “Email”, but I’m using Filemaker v5.5.1 - is there some bug in v5.5.1 that is fixed in v6?

I don’t know. You might be able to find out at the FileMaker Updaters page.

OK, I downloaded the Filemaker 5.5v2 updater and now it works. Thanks!!!

Glad Rob’s script worked. One note, though: if you’re running it within a FileMaker Perform AppleScript command, you don’t need the tell app “FileMaker” part, since it is redundant. I’ve seen that sometimes cause strange behavior.

If you upgrade to FileMaker 6 you can just use the Send Mail script step and use your email address field to send it to the To field in Mail. Creates the new message and addresses To:, Subject: and content.
Works fine.

The Send Mail command has been around for a while, but had erratic results when used with various email programs. Does it work much better now?

Also, with AppleScript you can actually control everything.