This is the first in a series of articles on using the Gmail API from FileMaker. We’ll provide free example files for each post and these examples will all use the native Insert From URL script step so there won’t be any plug-ins required.

In this article, we’re going to look at sending HTML emails. In future articles, I’ll examine sending large emails (35MB) with multiple attachments, resumable uploading, and managing threads. This approach provides a first-rate email experience that is not available using the native Send Mail script step. And, since the Insert From URL script step is supported natively across the whole FileMaker platform, the techniques shown here work on the Server, Go, FileMaker Cloud and WebDirect. This technique requires FileMaker 16 or higher since we’ll be using the advanced cURL options introduced in FileMaker 16.

Here’s an introduction. Step-by-step instructions and an unlocked example file follow:

Background and Choosing the Gmail API

I recently had the opportunity to build a comprehensive Gmail integration into a client’s system. The main reason the client wanted to go the Gmail route was to have seamless integration with their native Gmail experience; at first they weren’t that interested in threads or large attachments, but those features soon became important once they started emailing from within FileMaker.

Before we started, the client and I discussed which route we wanted to take, like using a plug-in or rolling our own. Fortunately, right about this time, dbservices published a great blog post and example file on integrating with the Gmail API. This article provided great techniques for authenticating to Google as well as creating an inbox in FileMaker that would import Gmails with their attachments. Basically, they had already done a lot of the work we needed. I implemented their authentication and inbox routine and then added the techniques I’m going to share here.

Example File

Please download the example file FM2Gmail for a working demo. This first version just covers the sending of HTML emails and we’ll be providing later versions of this file in future articles.

Integrating FileMaker and Gmail - Example File

FM2Gmail Example File


Getting Started / Authentication

Before we can send any emails, we’ll need to authenticate our app to Google. Our example file has adapted the authentication routine provided by dbservices where you’ll find more details on setting up a Google project for the OAuth values. Specify Web Application for your project so the redirect URI value is available. Once you’ve got your Client ID and Client Secret you can enter them into the fields on the OAuth settings page.

Integrating FileMaker with Gmail - Settings

Settings Popover


Authenticating Google Account within FileMaker

Authentication Set-Up

With your Client ID and Client Secret entered, you can click the “authenticate to gmail” link on the left. This opens a web viewer in a card window where you can log-into your Google account and authorize access to your Gmail data.

Authorize FileMaker to access Gmail

Authorize your app to access Gmail data

When you’ve successfully authenticated and authorized you’ll see your email address take the place of the “authenticate to gmail” link.


At this point, the example file has an authorization Refresh Token which we’ll use to automatically authenticate when the file opens in the future. So take some care with the file once it’s authorized as it will have access to your Gmail when opened. You can de-authorize the app access at any time by visiting “My Account” from your Google settings and then finding Apps with account access section. From there you can de-authorize the app.

Integrating FileMaker and Gmail Authorization

Remove app access from Google

Sending an HTML Email from FileMaker

Now that we’re authorized, the new email button appears, and we can compose and send something. I was going to use a card window for the compose layout, but I wanted to expose the formatting bar so went with a Floating window instead. (Exposing the formatting bar is an old FileMaker Hacks trick). Showing the formatting bar lets you easily add some styles to our text; those text styles will get transformed into styled HTML.]

Compose HTML email in FIleMaker

Composing an email with styled text

I also added a simple emoji picker for fun. These are just button bars that are passing the emoji characters into the text. Since we’re just using the unicode characters, the emojis are a little spartan on Windows but work fine for a simple demo.

Emoji Picker for FileMaker

An Emoji Picker

We can then send our Email and when we look at it in the recipient’s inbox we see that the styling has come across as an HTML email.



Under The Hood

To send an email via the Gmail API we first need to create the email form following the RFC822 standard. This multipart form may be familiar to many of you already and looks like the following:


In our sample file, the Script “Create RFC822 Form” is used to build the above. The RFC822 standard does call out using CRLF (carriage return + line feed) for the line breaks, but I had better luck just using the line feed or Char(10) in FileMaker terms. This allowed for leaving header values like CC blank and a more straightforward template.

Notice that there are two parts to this form that contains the message. The first is the text/plain section where we pass the plain text from our field. Since this is plain text, all of the formattings we applied is gone. Below, in the text/html section, we pass in the HTML representation of our message with any appropriate styling. Even though most modern email clients and browsers support reading HTML messages, it’s considered best practice to pass the plaintext message as well.

To generate the HTML in our sample file we’re just using FileMaker’s GetAsCSS() function. This actually works very well for a basic example and translates all of the formatting options except for any fonts applied. If you need a more robust HTML editor then something like FMEasyHTML from Tim Dietrich or Editor by Geist Interactive are worth checking out.

The Script “Send Email – Simple”

Once we have our form built, then we can POST it to the Gmail API using the Insert From URL script step. The example file does this in the script “Send Email – Simple”. Here’s what that script does:

Our target URL is:


This is the endpoint for our simple upload example and it supports an email up to 5MB. In the next article, we’ll be looking at a different URL that allows for up to 35MB with multiple attachments.

Now we just need to set a few cURL settings for our headers. (The exaple file writes the access token to a global variable when authentication is complete).

And then specify our request body which is the rfc822 form we created above.

And also capture the result headers to a variable in case we need to examine them for errors.

That’s it!. This is all done in the script Send Email – Simple so you can step through there to see how it’s put together.

If there’s an error in the POST, an error code and message will be returned in the response body and headers. Otherwise, you’ll get a simple JSON response like this indicating the email has been sent.

Our script grabs the id and the thread id and writes those to the email record in FileMaker as we’ll be looking at using those in a future example.


Even though there is some extra effort involved in accessing the Gmail API, like authentication, understanding the syntax, and cURL requirements, the benefits provided by the API are well worth it. Having techniques that work across all aspects of the FileMaker platform to extend your app’s email functionality can provide massive value to your customers.

Additionally, as FileMaker developers, our understanding this kind of integration is going to be more and more expected as FileMaker continues to focus on integrating with other platforms. From my experience, every integration I do with a new API makes the next one easier. Even if you don’t have an immediate need for Gmail integration, running through this process and understanding how this API works with something familiar, like email, can only make you a better FileMaker developer.

Here’s the next article in this series:

Integrating FileMaker and Gmail Part 2 – Sending Large Attachments

Tagged with →  

18 Responses to Integrating FileMaker and Gmail Part 1 – Sending HTML Emails

  1. Daniel Farnan says:

    This is a nice implementation, Jason – thank you for providing it!

    I would note, however, that the Gmail API documentation ( specifies using the RFC2822 standard and not the RFC822 mentioned in your article. For most purposes there is a negligible difference between the two, but it’s worth paying attention to this sort of thing in case those rare errors show up.

    I also note that RFC2822 was superseded in 2008 by RFC5322 (, so the Gmail API may be upgraded at some point to make use of the new standard.

    • Jason Young says:

      Hey Daniel,
      Thank you very much for pointing that out. I was going by the Content-Type headers in the docs on uploading media that all still reference message/rfc822. I’ll make some edits to the original post and to my upcoming ones to make this more clear.
      Thank Again!!

  2. Jim says:

    Thank you for the article. It is something I’ve considering doing but was not sure where to start or how much was involved.

  3. Will Bullard says:

    As always a great SeedCode video that enriches the FileMaker community with new options to explore. Thanks for sharing these techniques.

  4. Kudos ! Great article as always :)

  5. Joe Byrne says:

    Excellent. When is Part II coming? Can’t wait!

  6. Filza Naveed says:

    If you’re looking for a way to send responsive HTML email templates or newsletters from Gmail without the help of a designer, developer or coding knowledge, you should check out ContactMonkey’s solution for sending HTML emails from Gmail.

    They have engineered a way in which you can easily create responsive HTML email templates with their easy to use drag and drop builder and then send straight from your Gmail to your mailing lists.

    Here’s a step by step guide on sending HTML from Gmail:

    This is really great for internal communicators or internal marketers who want to send and track responsive employee newsletters from Gmail!

  7. Excellent post!

    Something that might be of help is this guide showing you how to create HTML, responsive emails from Gmail. Let me know what you guys think:

  8. It seems the Web Viewer to Authenticate a Gmail account is not working in WebDirect. Is this the case or am I doing something wrong?

    On the FM2Gmail file I turned on the WebDirect Extended Privileges, but when I try to “authenticate to gmail” I get a white screen.

    • Jason Young says:

      Hi Joseph,
      Yes, the authentication part of the demo file won’t work in WebDirect as you can’t “scrape” the tokens using GetLayoutObjectAttribute in WD. You would need to authenticate in Pro or Go and once you have the refresh token, then I believe most things will work in WD.

      Insert From URL is fully supported in WD, so all of the send and receive steps are supported.


  9. Frank says:

    Overall, excellent work. However, it seems that replies to FM with attachments are not processed correctly. The thread count is updated while the received email text is not shown nor are any attachments i.e. the incoming reply appears to be an empty email.

  10. Clem says:

    Hi Jason,
    For your information, I have also now determined that if a reply to an email sent from FM is sent in plain text that the email is not received in FM at all. Perhaps plain text strips out the threadid.


  11. Congratulations, great job! This is my scenario: several people work on the same filemaker, they all have their email in G Suite. I generated the Google project and OAuth values. I would like that the various users can send emails from Filemaker, where each user’s email and password are registered, directly without going through authentication or anything else. Is it possible?

    • Jason Young says:

      Hi Luigi,

      I hope all is well. The sending email address is bound to the tokens, so the users would need to go through the OAuth process once to get their own refresh token. With Google, the refresh tokens generally don’t expire unless they’re revoked, so it should be a one time process.

      Another option would be to use SMTP rather than https, which has been supported by FileMaker’s Insert From URL since version 17. It’s a similar process as we show here, e.g. building the form, but with SMTP, you can do the authentication with the Google user name and password instead of a token, but this means you’d need to store those credentials in FileMaker, as opposed to storing the Refresh Token. There’s a good post on doing this with SMTP here:


      • Luigi Corte Rappis says:

        Great, I think that’s exactly what I need. Thank you!

      • Tom Z says:


        This is a great article on how to use an API and OAuth
        However is it the point to integrate OAuth with FileMaker so user are able to send email using Gmail? as of today, smtp is using old fashion authentication which is user name and password. This method is not acceptable this days, especially with Gmail. To use smtp and username -password for authentication users will have to turn on Less Secure Apps in their Google account. While this was available for the last 2 year, starting from 15 Feb 2021 the LSA are no more support and Gmail users will no longer be able to turn on this feature in their Google account. Therefore it might be not possible for users to send emails from FileMaker.
        I believe by integrating an API and OAuth will allow to not only have better “Gmail” like experience but actually to be able to send email and comply with latest security protocols.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share →
DayBack Calendar
DayBack's 30-day trial is unlocked so you can customize it and integrate it with your files.
Download DayBack and we'll send you a couple short emails with tips on how to modify it and use some of the coolest features.
Thank you! Please download: DayBack Calendar
Need More?
SeedCode tips & example files in your inbox
Need More?
SeedCode tips & example files in your inbox
Want More?
Be the first to see articles and tips like these
Download TimeZync and we'll send you a couple short emails with tips syncing your FileMaker Go files.
Thank you! Please download: TimeZync
Want More?
Be the first to see articles and tips like these