Sending an email containing fields from a specific record in Filemaker
This will show how to create a button within Filemaker that, when clicked, will send an email containing any desired fields to a specific email address or to multiple email addresses.
The first step is to create a new script that will do the emailing, which you can do from Scripts -> Manage Scripts, then click "New".
- Under the 'Miscellaneous' category, there is an existing script "Send Mail", double click on that.
- By default, that script will use the client's email program to send the email; however, that is not likely what we want as we likely just want the email to be sent immediately upon submission and not requiring the user to have to have their email client opened. So, we will have to change the email type from client to SMTP.
- After having selected 'Send Mail' as your current script, double click on 'Send Mail [Send via E-mail Client]' to modify it.
- First, change the 'Send via' option from E-mail Client, to SMTP Server. After doing that, a new window will be displayed allowing you to configure the SMTP server, as seen below:
- All of the options in the 'SMTP Options' window pertain to the SMTP server, and hence, the name and email address entered into this form will be who the email is sent from.
- The SMTP server and port settings under Server Information in the 'SMTP Options' window are the correct settings when using a gmail SMTP server.
- Now you need to configure where the email is sent and what information to include in the email. Ideally you will have fields in your database that are populated with all the information required to send the email, and you should use those fields to populate the "Send Mail Options" form.
The image below shows an example from a database named TestMail, and it has defined fields of SendTo, Subject and Message and those are used to populate the email.
- Now that the script has been completed, you need to add a button to your table and associate the newly created script with that button.
- The button icon is the one in the red rectangle below
- After inserting a button, the 'Button Setup' window will be displayed and you need to choose 'Perform Script' under the 'Control' options, and then click the 'Specify' button to attach the script that you created previously to the button, as seen below.