Jump to content
Sign in to follow this  

Sending E-mail for FMP 4.x

Recommended Posts

The "Send Mail" script step in FileMaker Pro 4.x is extremely useful, but FMP does not send the mail itself: it passes the message onto the default mail client program on the machine that is running the script.

Unfortunately for Macintosh users, the only mail client software FMP4.x works with is Eudora and Claris Emailer.

However there is a work-around that uses the "Open URL" script step and the "mailto:" URL type. The mailto: string can contain subject and body information as well as the recipient address. The Open URL script step passes the data onto the computer's default web browser instead of the email client. It'll work as long as the web browser can send mailto: messages. This includes Netscape Navigator but currently excludes Internet Explorer (but check it yourself, things change quickly).

To make the magic happen, create a calculation text field that joins up all of the recipient, subject and body data into one long text string...

"mailto:" & emailfield & "?subject=" & subjectfield & "&body=" & bodyfield

...where "emailfield" etc are fields in the database with the relevant information.

Cc fields can also be specified: use the syntax "?cc=" but only include it if you have a Cc recipient. A case statement would take care of that:

Case(not IsEmpty(ccfield), "?cc=" & ccfield)

Note that because the subject and body fields will have some HTTP reserved characters in them (like <, >, &, spaces etc) they need to be "converted" into their http equivilents -- an easy task with the External("Web-ToHTTP", field) function. In this case the calculation will look like:

"mailto:" & emailfield & "?subject=" & External("Web-ToHTTP", subjectfield) & "&body=" & External("Web-ToHTTP", bodyfield)

OK we have the calculation text field done. Define a script that finds and sorts the records etc, and use the step "Open URL" based on the calculation field just created.

There are limitations to this method however: attachments won't work, and messages get queued in your email client, not sent immediately.




The External("Web-ToHTTP") function is only available if the Web Companion plug-in is enabled. It probably won't be on client machines, in which case the Open URL step will create a new email message in the browser but the subject and body text won't appear.

There are two solutions: activate the WC plugin on all client machines (very undesirable, can cause port conflicts and open up security holes) or use the Substitute() function instead -- no downsides other than it's less elegant.

The Substitute() function requires hard-coding each text string equivilent individually, by nesting a separate Substitute function for each string -- a lot of work to do each posible equivilent. However for my application I found that just two substitutions -- space=%20, carriage return=%0d -- was enough for my purpose.

The calculation that I used with the Substitution() function looked like this:

"mailto:" & Emailfield & "?subject=" & Substitute(Substitute(subjectfield, " ", "%20"), "

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.