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