Jump to content

Scripting Email


This topic is 7834 days old. Please don't post here. Open a new topic instead.

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 [email protected] 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:


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://[email protected]

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://[email protected]?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:



Link to comment
Share on other sites

This topic is 7834 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

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