SMTPit Pro contains two different prebuilt email windows. The email windows resemble a normal email client window, and allow you to send an email message without actually having to create a special layout or special fields. This example demonstrates the email window at its very basic functionality. To see the full functionality of the email windows, view the “Email Window (Advanced)” example which demonstrates hierarchal menus, using container fields for attachments, the merge field contextual menu, and more.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 section.
Download Example File
- 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 with Dialog (Simple) Script
SMTPit_Clear & “¶” & SMTPit_SetHost( Email::Host ; Email::Port ) & “¶” & SMTPit_SetAuthentication( Email::Authentication Type ; Email::Username ; Email::Password ; Email::UseSSL ) & “¶” & SMTPit_SetFrom( Email::From ) & “¶” & SMTPit_SendWithDialog( “Simple” )
The SMTPit_Clear function simply clears any settings from previous emails that were sent. The SetHost function sets the mail server host and port number from the “Host” and “Port” fields. SetAuthentication function sets the Authentication type, username, password, and whether to use SSL from the respective fields. The SetFrom function sets the From Address from the “From” field. The From Address is set in this field because the “Simple” Email Window does not allow you to edit the From address, so it needs to be set prior to opening the Email Window. The “Advanced” version of the Email window does allow you to change the From address, so it would not be necessary to set this if you were only using the “Advanced” version.
Note, all of the settings (SetHost, SetAuthentication, and SetFrom) can be set in the configuration dialog mentioned in the Settings tab of this documentation, so you do not have to use the functions if you prefer to set the items in the configuration dialog.
Finally, to actually open the “Simple” Email Window, the SMTPit_SendWithDialog function is called as follows:
SMTPit_SendWithDialog( “Simple” )
SMTPit_SendWithDialog( “Simple” ) This function can be used in any place you can use the FileMaker calculation engine. One of the best places to use it is in the “Set Field” or “Set Variable” button/script steps.
Send with Dialog (Advanced) Script
The Advance Email Window contains much more functionality than the Simple Email Window. It includes a CC and BCC field, and you can edit the From address. You can have an unlimited number of attachments, and the attachments mechanism is much more flexible that the simple version. Take a look at the “Send with Dialog (Advanced)” script. The calculation of the Set Field step looks like:
SMTPit_Clear & “¶” & SMTPit_SetHost( Email::Host ; Email::Port ) & “¶” & SMTPit_SetAuthentication( Email::Authentication Type ; Email::Username ; Email::Password ; Email::UseSSL ) & “¶” & SMTPit_SetFrom( Email::From ) & “¶” & SMTPit_SendWithDialog( “Advanced” )
Notice the code looks exactly the same as the “Send with Dialog (Simple) Script, with the exception of the SMTPit_SendWithDialog function. Setting the parameter to ”Advanced“ makes the ”Advanced" Email Window open.
To see this function used in a more feature rich example, view the “Email Window (Advanced)” example which demonstrates the use of hierarchal email address menus, using container fields for attachments, and using the merge field contextual menu.
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
Here are the steps to recreate the buttons in your own solution:
- Create a field called “Result” (if you do not already have one).
- Open ScriptMaker from the “Scripts” menu.
- Create a new script and give it a name.
- Choose “Set Field” from the list of script steps.
- Click the “Specify” button next to the “Specify target field” check box and select your “Result” field.
- Click the “Specify” button next to the “Calculated result” label.
- Use the SMTPit_Clear, SMTPit_SetHost, SMTPit_SetAuthentication, and SMTPit_SetFrom functions if you are going to have those settings in fields in your database.
- Then, use the SMTPit_SendWithDialog function to call up the Email Window when the button is pressed. The function should be entered as follows, depending on which version of the Email Window you want to use:
SMTPit_SendWithDialog( “Simple” )
SMTPit_SendWithDialog( “Advanced” )
- Save the script and close ScriptMaker.
- Enter layout mode by going to the “View” menu and choosing “Layout Mode”.
- Create a new button using the button tool.
- Choose “Perform Script” from the list of button steps and select the script you created.