Product Logo

SMTPit Pro

Next Generation Email plug-in

Send Text Email (Script Steps)

Introduction

This example demonstrates the basic method of sending email with SMTPit Pro, which is done via script steps. Plug-in script steps were introduced in FileMaker Pro 16, so this example will only work in FileMaker Pro 16 or higher.
Send Text Email [Script Steps)

Download Example File

FileMaker 16+ Example

Use the Example

Before you can send email from this database, you will need to enter your Mail Server settings into the database. To enter your mail server settings, press the “Settings” button and then click “Open Script Workspace”. You are now viewing the Script Workspace where you can edit scripts. Find the “Set SMTP Settings” script and edit it.

SMTPit Set Host [ Host: “mail.domain.com”; Port (Optional): 25 ]
SMTPit Set Authentication [ Type: Auto; Username (Optional): “user@domain.com”; Password (Optional): “password”; TLS Type: None ]

Here you can enter your Host, Port, and Authentication including SSL.

Send Button

This button performs the “Send” script, and demonstrates a large feature set of sending a text based email with SMTPit Pro script steps by using all of the email fields on the layout. In order to send a very basic message, take a look at the “Send (Simple)” section. This example, however, takes advantage of several SMTPit Pro features including Reply-To, CC, BCC, Header, and Footer. It can be broken down into six basic steps including:

  • Clear previous values
  • Set host and authentication
  • Set from, reply-to, and other recipients
  • Set subject and priority
  • Set header, body, and footer
  • Send the message

Sending the email is accomplished by using several SMTPit Pro script steps. Be sure to check out the Script Steps, to gain a better understanding of what each script step is doing.

Send (Simple) Button

This button performs the “Send (Simple)” script and demonstrates how to send an email with only a few SMTPit Pro script steps. The script consists for four main parts:

  • Clear previous values
  • Set host and authentication
  • Set message values
  • Send the message

Clear Previous Values

It is important to clear out old values before setting new ones so that you do not get unexpected results. If you have set a value in a previous message that is not being set in the current message, the value from the previous message will still be used. For example, if you set a header in your previous message, but you are not setting the header in your current message, the header from the previous message will be used in your current message. The plug-in is purposefully set up this way so that you can set a value and then use it across several emails. For example, you may want to set the body with some specific text and then use a personalized header for each record in a found set. Under this circumstance, it makes sense to set the body once rather than for each record. Also note that you can clear specific values with the clear script step. Be sure to visit the Script Steps section.

Set Up Host and Authentication

You can set up the host and authentication a couple of different ways. You can do as the database does and use script steps, or you can use the SMTPit Pro configuration dialog.

Set Message Values

In this portion of the script, the “SMTPit Quick Set” script step is used to set the from, to, subject, and body. For more information on these script steps, be sure to check out the Script Steps section.

Send the Message

Finally, the email is actually sent using the “SMTPit Send” script step. This script step has a few optional parameters that can be used if you choose to. Again, take a look at the Script Steps section for more information.

Send (Hard Coded) Button

This button performs the “Send (Hard Coded)” script and is very similar to the “Send (Simple)” script. The “Send (Simple)” script uses fields to get the value for each SMTPit Pro script step, while the “Send (Hard Coded)” script uses text strings directly in the script steps.

For example, in the simple version, the “From”, “To”, “Subject”, and “Body” values are set as follows from fields.

SMTPit Quick Set [ From: Email::From ; To: Email::To ; Subject: Email::Subject ; Body: Email::Body ]

In the hard coded version, the values are stored directly in the script step as follows.

SMTPit Quick Set [ From: “from@domain.com” ; To: “to@domain.com” ; Subject: “My Subject” ; Body: “My text body” ]

You can mix and match the way you use functions. For example you could hard code the “From” address and use a field for the other values.

SMTPit Quick Set [ From: “from@domain.com” ; To: Email::To ; Subject: Email::Subject ; Body: Email::Body ]

You can even mix hard coded values and field values inside the same script step parameter. For example, you could hard code part of the subject and add field data to it as well, like the following.

SMTPit Quick Set [ From: “from@domain.com” ; To: Email::To ; Subject: “Some Text ” & Email::Subject ; Body: Email::Body ]