Product Logo

SMTPit Pro

A Feature-rich Email plug-in

Send Text Email

Introduction

This example demonstrates the basics of using SMTPit Pro. There are several buttons along the top of the layout including “Send”, “Send (Simple)”, and “Send (Hard Coded)”. These buttons use the “Set Field” script step to do their magic. All of them set the field “Results” which is a global field.

To begin testing this example, first click on the button labeled “Settings” and enter your email information. At bare minimum, you will need to enter your email host. For more information about the settings layout, view the Settings tab.

Send Text Email example database

Download Example File

FileMaker 7–11 Example

FileMaker 12+ Example

Settings

Before you can send email from this database, you will need to enter a few settings. At bare minimum, you will need to enter your email host. The default host port is 25, but you may need to change this depending on your email server. If your email server requires authentication, you will need to choose an authentication type and enter your username and password. If your email server requires an SSL connection, you can set the SSL field to the correct SSL type. If you are unsure of which type to use, try both to see which works.

SMTPit Pro will always return information back to you when you make a function call. You can also get a transcript of of the interaction between SMTPit Pro and your mail server by setting the field “Get Transcript” to true.

All of the fields mentioned above are used in various calculations throughout the example database. This approach allows the database to be portable in a sense because the database can be moved to a different computer without losing the settings.

Another approach for storing settings is to use the default values in the SMTPit Pro configuration dialog. In the configuration dialog you can add default headers and footers, and other various settings. These preferences will be stored on your computer only, so if you move a database to a different computer, you will need to visit the preferences dialog to enter your settings. There are advantages to using both methods, and it will be up to you to decide which one will fit your needs.

Need help? Don't know what to use as your Settings or getting errors when trying to send?
Take a look at this article.

Access the Plug-in

When using plug-ins (not just ours), they do not add new script steps, but instead add new functions that are available in the calculation engine.

To see a calculation that tells the plug-in what to do, go to the “Scripts” menu, and choose “Manage Scripts” or “ScriptMaker”. Once in Manage Scripts/ScriptMaker, double click on the “Send” script. Note that we are using the “Set Field” script step which consists of two settings. The “Specify target field” button allows you to choose which field you want to set. In our case we want to set the “Result” field. The second specify button is where the SMTPit Pro calculation exists. Click this button to see the calculation used to tell the plug-in what to do.

In this calculation, the plug-in is accessed using the “SMTPit_FunctionName” functions. There are many functions allowing you to do different things such as set the To address, Subject, and etc. For a complete listing of the functions available, see the Functions tab. You can also access the functions in a “Specify Calculation” window by clicking the “View” menu, then selecting “External Functions”, and then scrolling through the list until you find the plug-in name.

Send Button

This script demonstrates a large feature set of sending a text based message with SMTPit Pro. It uses all of the email fields on this layout. In order to send a message with the pure basics, take a look at the “Send (Simple)” tab. This example, however, takes advantage of several SMTPit Pro features including Reply-To, CC, BCC, Header, and Footer.

The calculation has several comments in it to help clarify what all it is doing. To see how to view the calculation, look at the “Accessing the Plug-in” tab. It can be broken down into six basic steps including:

  1. Clear previous values
  2. Set host and authentication
  3. Set from, Reply-To, and other recipients
  4. Set subject and priority
  5. Set header, body, and footer
  6. Send the message
Sending the email is accomplished by using several SMTPit Pro functions. Be sure to check out the Functions tab, to gain a better understanding of what each function is capable of doing.

Send (Simple) Button

This script demonstrates how to send a message with only a few SMTPit Pro functions. To see how to view the calculation, view the “View Calculation” tab.

The calculation consists for four main parts:

  1. Clear previous values
  2. Set Up Host and Authentication
  3. Set Message Values
  4. 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 function. Be sure to visit the Functions tab.

##Set Up Host and Authentication

You can set up the host and authentication a couple of different ways. You can do as we have here and use functions, or you can use the SMTPit Pro configuration dialog. It may be that your specific host does not even support authentication. It is up to you to determine what approach will best suit your needs.

##Set Message Values

In this portion of the calculation, we set the from, to, subject, and body. For more information on these functions, be sure to check out the “Function Reference” or click on the function names.

##Send the Message

Finally, we send the message using the SMTPit_Send function. The send function has two optional parameters that you can use if so desired. Again, take a look at the “Function Reference” or click on the SMTPit_Send function for a full description.

##Conclusion…

If you take out all of the comments, and your host and authentication is set up in the SMTPit Pro preferences, you could use the following calculation to send this basic message, and the result field will return the status of each function in a readable manner:

SMTPit_Clear & “¶” & SMTPit_SetFrom( Email::From ) & “¶” & SMTPit_SetTo( Email::To ) & “¶” & SMTPit_SetSubject( Email::Subject ) & “¶” & SMTPit_SetBody( Email::Body ) & “¶” & SMTPit_Send

Send (Hard Coded) Button

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

For example, in the simple version, the “To” value is set as follows:

SMTPit_SetTo( Email::To )

In the hard coded version, the “To” is set as follows where “to@yourdomain.com” should be replace with a real email address:

SMTPit_SetTo( “to@yourdomain.com” )

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 “To” address, as follows:

SMTPit_SetFrom( “from@yourdomain.com” )
& “¶” &
SMTPit_SetTo( Email::To )

You can even mix hard coded values and field values inside the same function:

SMTPit_SetSubject( "Some Text " & Email::Subject )

Using the hard coded approach could be used in several places in FileMaker. You could have a script that uses the “Set Field” script step to send an email once the script is complete. You could also have a text field that uses an auto-enter calculation to send a message when a new record is created. In other words, you can send an email in any calculation that FileMaker has available.

View Results

This example has a Send Result field where the Results are shown. This is where the plug-in can give you feedback on what it is doing. If an error occurs, it will report the error in the results field which can help you fix any issues you may be having. It will also report its successes so that you know everything is going as planned. If you have “Get Transcript” set to true on the settings layout, you will also see the interaction between SMTPit Pro and your mail server in the Result field.

Need help? Getting errors when trying to send?
Take a look at this article.

How to recreate in your solution

There are several ways to recreate these scripts in your own solution. The easiest way is to simply import the scripts through Manage Scripts/ScriptMaker and then edit so that the field names and strings match fields in your solution.

For example, you could import the “Send (Hard Coded)” script into your own solution and it would work as is, provided you have updated the values with your own information.

You could also import the “Send (Simple)” script to your own solution and then update each field to a field in your solution. For example, you would need to change the “Email::To” field reference to your own which could be something like “Contacts::To”. You may also want to hard code information such as the From setting.

You may also want to take a look at the Integrating the plug-in section in the documentation.