Receiving email, Part 3: Using email 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 Run a Workspace in Response to Incoming Email. Note that this tutorial series will no longer be updated, if you encounter an error, please contact Safe Support.

 

Introduction

This is the final article in the Receiving Email tutorial series. In this section, we will send an email to FME Server that has shapefile attached and show you how you can use the attachments in the workspace that will follow.

 

Prerequisites

 

Step-by-step Instructions

Preparing the Workspace

For the final part of the Receiving email series, you can either follow the steps below to extend on the workspace created in the previous section of this tutorial or download the attached zip file for a complete workspace.

  1. Add a FeatureReader after the Reader, set the format to Esri Shape, and for the dataset use the email_publisher_attachment{0} or imap_publisher_attachment{0} attribute, respective of whether you used the SMTP or IMAP publisher.
     

    Note: If the email body includes images these will also appear in the _publisher_attachment{} list so you may need to filter your result by type first. One way to do this could be to use a ListSearcher to find which element of the list contains the xml path.listsearcher.png

    Search for .xml in publisher_attachment list to identify correct list index to use if there is more than one
     
  2. To read all incoming feature types, simply leave the Feature Types to Read parameter under the Constraints section unset. It will display <All Feature Types>.
  3. At the bottom of the parameter editor under Output Ports change the selection to Single Output Port. Alternatively, leave it on the default setting to have each output feature type as a separate port, or if you are only interested in specific feature types, you can set them by manually entering a list or an attribute.
  4. Connect a KML Writer to the <Generic> port and set the destination path to a location on the server using the FME Server Parameters, i.e. $(FME_SHAREDRESOURCE_DATA)\<folder>\<filename>

workspace.png

Receive Email 3 final workspace

 

Publishing the workspace

This workspace could be published to the Notification service, using the same method described in Receiving Email, Part 2, but for this example we will instead use Workspace Subscriber

  1. Publish the workspace to FME Server, and go through the steps up to “Register Services”.
  2. Select the Job Submitter Service for workspace registration and finish publishing the workspace.

 

Create a Workspace Subscription

  1. Go to the FME Server Web Interface and under Notifications > Subscriptions select New.
  2. Give your Subscription a Name, select FME Workspace as the protocol and subscribe this workspace to the RECEIVE_EMAIL topic set up in the previous section of this tutorial
  3. Once you have selected the recently published workspace the Source JSON published parameter will appear, check the box to the right-hand side that states ‘Get Value from Topic Message’.
  4. Leave the Notifications and Advanced settings of the Subscription blank.

subscription.png

FME Workspace Subscription

It is important to ensure that box is selected so that the Reader will pick up the incoming message posted from the Topic to pass the attachment path into the FeatureReader.

 

Testing the Subscription

To test that the subscription service has been correctly set up, send an email with a zipped shapefile attached l to the user account publication that we set up to post to the RECEIVE_EMAIL topic.

In the FME Server Web UI you should see the ReceiveEmailPart3.fmw listed in the Completed Job History. View the job log to confirm the attachment was correctly processed.

sourcejson.png

Receive Email workspaces uses the Topic Message as the JSON Source Dataset

readerattachment.png

Email attachment being processed in the workspace

 

Conclusion

This tutorial adds support for processing attachments. While it only does a simple conversion, the process opens up many possibilities.

This workspace could, for example, be the starting point for a data distribution process. Users could email in a file. FME Server would then process it, and place it in a shared network location or Dropbox folder.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.