Sending Email with Merge Fields

What would a database solution be without the ability to send email? Well, it would be a database solution without the ability to send email - but who wants that right?

Email is obviously an integral part of our modern day communication. And, despite what the Twitters, Facebooks and Instagrams of the world would have you believe, email is here to stay.

The easiest way to add email support to a FileMaker database is to simply use the Send Mail script step. But, that’s boring, and sometimes it doesn’t work. Especially when you’re using an email client not supported by FileMaker. The Send Mail step alone also has limited use when, most of the time, the intended objective is to integrate data from the database.

Therefore, we need to integrate the data from our fields. The easiest way to do this is to use FileMaker’s <<mergeFields>> right within the content of a text block somewhere on the layout, or off to the side of the layout, and then using the function GetLayoutObjectAttribute ( “My_Merge_Email” ; "content" ).

The problem we hit is that this is not user friendly. You don’t often give users the ability to edit layouts. So why not emulate the way FileMaker works with merge fields and simply do the same thing using data which is stored within fields?

This video showcases one of the most streamlined and easy-to-implement solutions for handling merge values into content stored within a field. Using the content provided here you’ll have an email merging and sending solution within mere minutes every time you need it!

AttachmentSize
SendingEmailMergeFields.zip388.62 KB

Comments

Interesting Matt,

I have but one question - can you send attachments using mailto? I have done a quick search and found that this cannot be done reliably. Any thoughts?

Thanks

Tim

You can't specify attachments with mailto links. Using a mailto: is a one way event where FileMaker is handing things off to the OS and then from there you can't get a response back into FileMaker to know the id of the message created.

If you are doing things on a Mac then you can use AppleScript to make the attachment happen. On Windows, I'm unfamiliar with the process.

Ultimately, if sending attachments, especially multiple, is needed, then your best bet is using a Plugin. This can be done either client side or server side.

My personal preference is the MBS plugin sending emails with attachments from the server. This allows me to use FileMaker Go and the server can access files from many of the various cloud storage services.

-- Matt Petrowsky - ISO FileMaker Magazine Editor

Great update to this method. The email method is very interesting. I'll have to do more research on that as I use outlook.

"ms-outlook://compose?"
& GetAsURLEncoded ( $subject )
& "&body="
& GetAsURLEncoded ( $content )
& If ( not IsEmpty ( Send::SEND_TO ) ; "&to=" & GetAsURLEncoded ( Send::SEND_TO ) )
& If ( not IsEmpty ( Send::SEND_CC ) ; "&cc=" & GetAsURLEncoded ( Send::SEND_CC ) )
& If ( not IsEmpty ( Send::SEND_BCC ) ; "&bcc=" & GetAsURLEncoded ( Send::SEND_BCC ) )

-- Matt Petrowsky - ISO FileMaker Magazine Editor

Hey Matt, awesome content on your site. Have a question though. Is it possible to generate the data from a developer page with all the merge fields. I'm currently stuck with the GetLayoutObjectAttribute wanting to grab it from the local layout rather then the specified layout where I have all the merge variables on. Would be great if we could do this.