Sending email, Part 5: Sending an email with attachments

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2018.x

As of FME Server 2019+, this functionality can be completed using FME Server Automations. For more information, please see Send Emails with Attachments From FME Server 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 Tutorial: Email in FME Server. This is the fifth article in the sending emails series. This article will cover how to send emails with attachments through the FME Server.

 

Prerequisites

  • FME Server 2016 or later installed
  • FME Desktop installed
  • Set up for sending email according to the documentation
  • Completion of Sending email, Part 1, Part 2

 

Step-by-step Instructions

As covered in part 2, in order to send an email from a workspace, you must generate the JSON for the email notification and then notify the Server. To add support for attachments, the email_attachment keyword needs adding to the JSON with a path to the file you wish to send. The FMEServerEmailGenerator handles this automatically for us.
 

Preparing the workspace

You can use the workspace from part 2 of the tutorial, or download the attached fmw file.

  • Add an AttributeCreator immediately after the Creator transformer, and for each file you wish to attach create an attachment for, add an attribute with a path to the file. You may attach the sample text file included in this tutorial. Note, depending on the SMTP provider you are using, there will be limits on the size of the file you can attach. For example, in Gmail the limit is 25MB. Additionally, the path to the data must be accessible to the FME Server Engine that runs the job.

img1attribute.png

  • Open the FMEServerEmailGenerator transformer and, in the attachments field, select the attributes you have just created.

img2attachment.png

 

Publishing and running the workspace

  • Publish the workspace to FME Server, selecting the Job Submitter service.
  • Run the workspace on FME Server. If the workspace was successful, you should receive an email shortly.

 

Troubleshooting

The path to the data must be accessible to the FME Server Engine that runs the job. You should either be pointing to data locally on the server, or on an accessibly shared drive (e.g. UNC path) if you are using on-premises FME Server. Alternatively, you can use the Resources folders to store the data for the attachments [e.g $(FME_SHAREDRESOURCE_MYDATA)/Parks.zip].

If you don’t receive an email, you can do the following to troubleshoot:
Enable monitoring on the SEND_EMAIL topic in the FME Server web interface. This will show you what content is being received on the topic.

If JSON content is being received in the topic, your SMTP settings are probably incorrect. Review them, and try again.

For more information about troubleshooting notifications with log files, see About Log Files in FME Server.
 

Conclusion

In this part of the tutorial, we’ve sent an email with an attachment using FME Server and an SMTP server. We did this from a workspace using the FMEServerEmailGenerator transformer but all this is doing is generating JSON and submitting it to the FME Server via the FMEServerNotifier transformer. 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.