fm7 mailsmith
August 18, 2005 7:17 AM   Subscribe

I'd like to be able to send an email from filemaker 7 to mailsmith. in filemaker 6 the send mail script would send to whatever the default mail client was. filemaker 7 seems only to talk to the apple mail program. is there anything I can do to fix it? thanks!
posted by cgt to Technology (1 answer total)
 
You can do it via AppleScript, but there's a catch. Unless you have FileMaker Developer, you can't create custom functions, so you have to supply all the parameters in FileMaker fields. Here's how we do it in our database, more or less:

"set theMsgBody to (" & "\"" & Temp Body Field & "\"" & ") as text" & "¶" &
"tell application " & "\"" & "Mailsmith.app" & "\"" & "¶" &
"set theMsgRef to (make new message window with properties {sending account:" & "\"" & "Sending Account Name Here" & "\"" & ", use signature: false})" & "¶" &
"make new to_recipient at end of theMsgRef with properties {address:" & "\"" & Temp To Field & "\"" & "}" & "¶" &
"set subject of message window 1 to " & "\"" Temp Subject Field & "\"" & "¶" &
"set contents of message window 1 to theMsgBody" & "¶" &
"queue message window 1" & "¶" &
"end tell" & "¶"


This is a calculation, and the result has all of the right field values substituted in. We put this in another temp field and have AppleScript execute the field. The result of the calculation is something like this:

set theMsgBody to ("...and thanks for all the fish!") as text
tell application "Mailsmith.app"
set theMsgRef to (make new message window with properties {sending account:"Our Sending Account", use signature:false})
make new to_recipient at end of theMsgRef with properties {address:"user@example.com"}
set subject of message window 1 to "So long..."
set contents of message window 1 to theMsgBody
queue message window 1
end tell


The real catch with this procedure is that none of the Temp fields (subject, body, to) can have quotation marks in them ("), because that will throw off the calculated AppleScript. We typically use single quotes, or if absolutely necessary, escape them. If you're calculating the body contents and using this technique, you escape a quote as
\\\"
After FileMaker calculates it, it collapses to
\"
and AppleScript interprets that as one ASCII 34 character.

Yeah, it's a boondoggle, but every mail client has a different scripting dictionary. That's one reason viruses to send E-mail don't take hold as easily on the Macintosh - there's not one script to rule them all.
posted by mdeatherage at 9:28 AM on August 18, 2005


« Older Cost to replace a Honda Civic Engine?   |   What on earth is this? Newer »
This thread is closed to new comments.