FME Version
Files
-
- 80 KB
- Download
As of FME Server 2019+, this functionality can be completed using FME Server Automations. For more information, please see Send email from Automations. Note that this tutorial series will no longer be updated, if you encounter an error, please contact Safe Support.
Introduction
This tutorial is part of the series Email in FME Server. This is the fourth article in the sending emails series. The previous article demonstrated how to send an email after a workspace completes. This tutorial will demonstrate how to send emails with HTML. This email will include a formatted header and hyperlinks which will be dynamically generated based on the user's input. This tutorial will produce the email below.
Prerequisites
- FME Server 2016 or later installed
- Access to an SMTP server (a Gmail account works)
- Part 3 of this tutorial completed
Step-by-step Instructions
Creating the workspace
We will be using the workspace from the previous section, but you could of course also use an FMEServerNotifier to send your email.
- Create a published parameter called LizardLocation. To create a published parameter, right click on the Published Parameters and select Create User Parameter. Fill in the following values in the User Parameter.
- Delete the connection between the Creator and FMEServerEmailGenerator.
- Add an AttributeCreator to the canvas. The input of the AttributeCreator should be attached to the Creator. Modify the parameters in the AttributeCreator. In the New Attribute column write LizardLocation. The Attribute Value should be the User Parameter LizardLocation.
- Next, replace spaces with “+” so that the Google Maps search is properly formatted. To do this add a StringReplacer to the canvas. Connect the input of the StringReplacer to the AttributeCreator. Then, connect the output to the FMEServerEmailGenerator. The Attributes should be LizardLocation, the Mode should be Replace Text, and the Replacement Text should be +.
- Modify the properties of FMEServerEmailGenerator. The HTML email message is entered in the content field. It is generally easier to edit HTML in the text editor. Please note, that to see the syntax highlighting above select Options > Syntax Highlighting > HTML.
<h1 style="font-family:Arial; color:#801020; background: #000; padding: 5px;">FME Lizard Spotted</h1> <p style="font-family:Arial;"> Reports indicate that the <a href="https://twitter.com/FMELizard">FME Lizard</a> has been spotted near <a href="https://maps.google.com/maps?q=@Value(LizardLocation)">$(LizardLocation)</a>.</p>
The completed workspace can be found at the beginning of this article.
Note, that not all email clients support <head></head> tags, so it is better to use inline styles, as in the example above. For more information about formatting, see the HTML and CSS references at http://www.w3schools.com/.
Publishing the workspace
You can simply republish the workspace. If you have created a new workspace or downloaded the provided one. Publish it as before by registering it with the Job Submitter Service. Select Edit and select SEND_EMAIL as the topic to publish to on success.
Configuring the topic
Since you will be sending a different MIME type (text/html instead of text/plain), you will need to configure this using the FME Server web interface.
- Go to Notifications > Subscriptions > SEND_EMAIL
- Change the email format to HTML
- Click OK
Running the workspace
You can now run the workspace via the Job Submitter service, and you should receive an HTML email.
Troubleshooting
Troubleshooting for this section of the tutorial is mostly the same as for the previous section. In case of HTML formatting not working correctly in your email, try to use the simplest formatting possible, and add to it gradually.
Conclusion
In this part of the tutorial, we’ve sent an email with HTML content. This allows you to format your content more effectively, increasing readability and allowing you to create links without needing to display the entire URL in the text.
Comments
0 comments
Please sign in to leave a comment.