Jump to content
Sign in to follow this  
Chuck

Scripting Email

Recommended Posts

There are three main options for sending an email using data from FileMaker.

1: Use the Send Mail script step. When a script is run with this step, the email is composed and ready to be sent from your email application's out box. This step has the advantage in that it's the most straight forward to use from within FileMaker. You add the step to your script and specify which fields have the email address, subject text, body text, etc.

The downside to this solution is that it only works with some email clients. On Windows it works with Microsoft Exchange or another email program that is MAPI (don't ask, I don't know what that means) compliant. On the Mac, it works with Em@ailer or Eudora. If you use anything else, it won't work.

2: Use the Open URL script step. Properly set up, this script step behaves like Send Mail, but it takes a bit more work to get it going. The reason is that you have to construct the URL. Most URLs that you're probably familiar with look like this:

http://www.filemaker.com

This is a URL for a web site. But URLs exist for email as well. Whenever you see a link for an email address on the web and when you click it you get a new message in your email program, you clicked an email URL. The simplest kind look like this:

mailto://chuck@rossclan.org

This tells the computer what kind of URL it is (a mail URL) and the address for the URL (my email address). But a mail URL can have more than just an email address. It can have a subject, cc, body, etc. Here's a URL that includes the subject:

mailto://chuck@rossclan.org?subject=FM Forums

So, if you have a field for the email address, a field for the subject, for the body, for the cc address and for the bcc address, you could create another field that has a calculation such as this:

"mailto://" & email_address & "?subject=" & subject & "?body=" & body & "?cc=" & cc & "?bcc=" bcc

You can make this more complex by checking whether there is anything in each of the fields before adding the tag for that field, like this:

"mailto://" & email_address & "?subject=" & subject & "?body=" & body & Case( not IsEmpty( cc ), "?cc=" & cc, "" ) & Case( not IsEmpty( bcc ), "?bcc=" bcc, "" )

Now if the cc or bcc fields are empty, those sections won't be included at all.

There's one more thing to know about this way of sending email. If you have paragraph returns in the body, or some other characters such as the ampersand (&), these may not show up properly, since such characters have to be encoded for the URL to work properly. I used to think that you had to know all of the codes, but Vaughan recently pointed out to me that there is a function in FileMaker that will take care of this for you. It's an external function of the Web Companion plug-in called "Web-ToHTTP", and it will replace all of the characters that might not work correctly with their http equivelants. Spaces will be replaced by %20, returns by %0d, etc. This nice thing about this function is that you don't have to worry about which characters need to have replacement codes. It does all the work for you.

Here's the above calculation with this function in place:

"mailto://" & email_address & External( "Web-ToHTTP", ( "?subject=" & subject & "?body=" & body & Case( not IsEmpty( cc ), "?cc=" & cc, "" ) & Case( not IsEmpty( bcc ), "?bcc=" bcc, "" ) )

I don't place this around the "mailto://" & email_address portion of the calc because mailto:// doesn't need it, and the email_address, if it's a legal address, shouldn't need it either.

For the full details on this function, check out FileMaker's online help. For this function to work, the Web Companion plug-in needs to be turned on.

3: Use a plug-in. There are a lot of plug-ins that give FileMaker itself emailing capabilities, negating the need for an outside email client. I've only used one, MondoMail, which only works for the Mac, but there are others which are cross platform. Using such plug-ins, you could conceivably make FileMaker your entire email client. Check out this web site for more information:

http://www.fmplugins.com/action.lasso?-database=plugins.fp3&-layout=list&-response=pluginlist.html&-noresultserror=error.html&-maxrecords=20&-token.did=&-search=&search=email

Chuck

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.

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