Sending email, Part 4: Sending prettier email using HTML

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

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.

img1fmelizard.png

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.

  1. 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.img3userparam.png
  2. Delete the connection between the Creator and FMEServerEmailGenerator.
  3. 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.img4attributecreator.png
  4. 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 +. img5stringreplacer.png
  5. 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. img2htmlemail.pngPlease 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.

  1. Go to Notifications > Subscriptions > SEND_EMAIL
  2. Change the email format to HTML
  3. Click OK

send-part4-2.png

 

Running the workspace

You can now run the workspace via the Job Submitter service, and you should receive an HTML email.
http_download_1444329595928_6032.png

 

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.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.