Skip to end of banner
Go to start of banner

Email Reader

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 38 Next »

In this article

Overview

You can use this Snap to read IMAP or POP3 server email messages. In addition to reading emails, you can also process inline images, images sent as attachments, archive read emails using this Snap. The Snap allows you to choose the target folder where such archived emails are moved, and you can use this feature to delete emails as well by configuring the corresponding 'trash' folder in your email.

Snap Type

Email Reader Snap is a READ-type Snap that reads the data and passes to the downstream Snap.

Prerequisites

This Snap requires a valid IMAP or POP 3 account to handle access to this endpoint.

Clicking the "Preview" button does not read any email message if the account is IMAP and the Unread only property is checked. When unread messages are read, they are all marked as "read" in the mail server. Therefore, they should not be read during the preview. Otherwise, the execution of the Snap will not be able to read any message.

Support for Ultra Pipelines

Works in Ultra Pipelines

Limitations

Gmail IMAP or POP3 accounts may not work with the Email Reader Snap. Gmail processes an email hijack detection based on IP addresses and locations. If it sees the IP address that the IMAP or POP3 client app is running from is different than the usual locations, it suspects the account is being hijacked and sends error messages like:

  • +OK Gpop ready for requests from 23.23.38.68 n18mb191678450qav" or

  • Cannot connect to the endpoint reason: [SYS/PERM] Your account is not enabled for POP access. Please visit your Gmail settings page and enable your account for POP access." or other variations.

You may find an email from Gmail in the inbox titled "Suspicious sign in prevented", which is caused by the execution of Email Reader Snap. You may be able to see more messages from Gmail in your Gmail account web page: Account > Security > Recent Activity > View activity. As of writing this note, there seems to be no settings available in the Gmail account to disable this security feature. Please contact Gmail Support if your Gmail account must work in Email Reader Snap.

Known Issues

None.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 0

  • Max: 1

Document

This Snap has at the most one document input view.

By default, the input view is not enabled; however, you can specify at the most one input.

Output

Document

  • Min: 1

  • Max: 1

Document

This Snap has exactly one output view and produces documents in the view. Each Document contains a Map data which represents one email message. The keys in the document are "from", "to", "cc", "subject", "dateSent", "emailType", "textBody", "htmlBody" and "attachments". The value of "from", "to" and "cc" keys is a list of strings. The value of "subject" and "dateSent" keys is a string.The value of "emailType" key is "text/plain" or "text/html" or "multipart/*". The value of "attachments" key is a list of Map data. Each Map data corresponds to an attached file. The keys of the Map data are "contentType", "filename" and "attachment". The value of the "attachment" key is a binary data read from the attached file. If the email message received has a nested multipart of content, all plain text bodies are appended to the value of the "textBody" key, and all HTML contents to the value of the "htmlBody" key. The following is an example of an Output Document:

{ from: "sender@example.com", to: "Snap@example.com; youto@example.com", cc: "meto@example.com", subject: "testing Email Sender Snap", emailType: "text/plain", textBody: "This is a sample email body.", htmlBody: "", dateSent: "Thu Mar 06 09:20:06 PST 2014", attachments: [ { contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name="bbskus.xlsx"", filename: "sldb:///Snaplogic/projects/attachments/bbskus.xlsx", status: "overwritten" } ] }

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution: Stops the current pipeline execution when the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the rest of the records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon ((blue star)): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ((blue star)): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ((blue star)): Indicates that you can add fields in the fieldset.

  • Remove icon ((blue star)): Indicates that you can remove fields from the fieldset.

Field Name

Field Type

Field Dependency

Description

Label*

Default ValueEmail Reader
ExampleEmail Reader

String

None

Specify the name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your Pipeline.

Mail folder*

Default Value: Inbox
Example: Inbox

String/Expression

None

Specify the name of email folder where the Snap reads messages from.

Ensure that you specify the folder name as it appears on the email client, because folder names might be case-sensitive for some email providers, such as Yahoo. Otherwise, the Snap displays Error retrieving folder for given source or destination error.

Unread only

Default Value: Selected
Example: Selected

Checkbox

None

Select this checkbox to inform Snap to read only the unread email messages. If you do not select this checkbox, the Snap reads all messages.

 If this property is selected, the Snap does not execute during preview as the execution changes the state of the unread messages.

Number of messages

Default Value: All
Example: 100

Integer

None

Specify the maximum number of messages that the Snap has to read. Any non-integer or negative value leads to "All" messages being moved.

Older message first

Default Value: Deselected
Example: Selected

Checkbox

None

Select this checkbox to view the older messages first in the output view. If you do not select this checkbox, the latest messages display first in the output view.

Attachment folder

Default Value: Shared
Example: smb://<username>@<hostname>:<port>/<directory>

String/Expression

None

Specify the URL of the directory where attached files are stored. If this property is blank, all attached files are ignored.

  • This property is expression-enabled. For more information on the expression language, see Expression Language Overview and Expression Language Usage.

  • The user must have write access to the target folder listed in this field.

  • If the Attachment folder is in the SMB file protocol, the name of the file attached to the Email must not contain any of the following characters:  " \ / : | < > * ?

The following are the most commonly-used target directory values:

  • shared: The Snap writes attachment files to /<org>/shared/ 

  • /<org>/projects/<project>: The Snap writes attachment files to the specified project.

  • sftp://<username>@<hostname>:<port>/<directory>:The Snap writes attachment files to the specified directory.

  • smb://<username>@<hostname>:<port>/<directory>: The Snap writes attachment files to the specified directory.

  • smb://<domain>;<username>@<hostname>:<port>/<directory>: The Snap writes attachment files to the specified directory. if the SMB credential has a Domain field, there should be a semicolon used as a separator between <domain> and <username>.

  • For SFTP and SMB paths, the password should be entered into the Attachment password property in the email account.

Examples:

  • sldb:///snaplogic/projects/attachments

  • $attachmentFolder

  • sftp://mrtest@sftp.snaplogic.com/home/mrtest/new/

  • smb://mydomain;snapuser@54.159.200.139:445/snapuser/

File action

Default ValueOVERWRITE
Example: RENAME

Dropdown list

None

Select an action to be taken if a file with the same name as in the email attachments exists in the specified directory. The available options include:

  • OVERWRITE

  • RENAME

  • IGNORE

  • ERROR

If ERROR is selected, the Snap displays an error message and the pipeline execution is terminated when it encounters an already existing file.

Archive messages after reading

Default ValueDeselected
Example: Selected

None

Select this checkbox to move or archive the read messages. If you do not select this checkbox, the read messages are not moved or archived.

Target folder

Value: None
Example: Archived

String/Suggestion

Archive messages after reading

Specify the target location for the archived emails. You need to configure this property only if you select the Archive messages after reading field. This is a suggestible field and the suggestions are based on the folders available in the email account.  

Ensure that you specify the folder name as it appears on the email client, because folder names might be case-sensitive for some email providers, such as Yahoo. Otherwise, the Snap displays Error retrieving folder for given source or destination error.

Snap Execution

Default ValueValidate & Execute
Example: Execute only

Dropdown list

N/A

Select one of the three modes in which the Snap executes. Available options are:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during Pipeline runtime.

  • Execute only: Performs full execution of the Snap during Pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Examples

Reading Attachment from an SFTP Location

In this pipeline, the Email Reader Snap reads the attachment from the path as provided in the Attachment folder field, in this case, from an SFTP location. 

The Email Reader Snap is configured as in the following image:

email-reader-example.png

In order to read and store the files on a provided location, the Attachment password must be set on the Account Settings of the Snap, else will display an error.

email-account-config.png

Reading Emails from Shared Mailbox

The pipeline below demonstrates how the Email Reader Snap is used to read emails from shared mailboxes:

The Snap's configuration is the same as in reading emails from individual mailboxes, however the Account settings are to be configured a little differently:

  • Email ID - email ID suffixed with "/shared-mailbox". For example, abc@hotmail.com/shared-mailbox

  • Mail properties fields:

    • Mail property name: mail.imaps.auth.plain.disable

    • Mail property value: true

The screenshot below is a sample of the Account settings for such a configuration:

email-reader-shared.png

Validate the account and click Apply. If the mail properties are not configured the validation fails with an exception.

The Email Reader Snap is configured the same way as in individual mailboxes, in the Mail folder property, the folders from the shared mailbox are suggested as seen in the screenshot below:

A sample preview of the output data showing one of the emails in the shared mailbox.

Archiving Read Emails

The emails read by the Snap can be archived/moved to a specified target location using this Snap. In this example, the emails are moved to the Spam folder. The pipeline is as shown in the screenshot below:

The Email Reader Snap is configured as shown in the screenshot below:

The Archive messages after reading property is selected and the target folder is specified as the Spam folder.

The screenshot below shows the Inbox of the email account with an email. This email will be archived and moved to the Spam folder when the Snap is executed.

Below is a preview of the output from the Snap, it shows the body of the email along with other email attributes:

When refreshed, it can be seen that the Inbox has been updated and the email moved to the Spam folder:

Deleting Emails Using the Archive Feature

The emails read by the Snap can be archived/moved to a specified target location using this Snap. In this example, the emails are moved to the Trash folder. The pipeline is as shown in the screenshot below:

The Email Reader Snap is configured as shown in the screenshot below:

The Archive messages after reading property is selected and the target folder is specified as the Trash folder.

The screenshot below shows the Inbox of the email account with an email. This email will be archived and moved to the Trash folder when the Snap is executed.

Below is a preview of the output from the Snap, it shows the body of the email along with other email attributes:

When refreshed, it can be seen that the Inbox has been updated and the email moved to the Trash folder:

Reading Inline Images

The pipeline in this example, Reading_Inline_Attachment_Images.slp, demonstrates the image reading functionality of the File Reader Snap. An email containing an inline image and an image as an attachment is passed to the Email Reader Snap.

Upon execution, the output preview shows the inline and attached image.

Download this pipeline.

We have an email in a Gmail account inbox that contains both an inline image and an image as an attachment:

The pipeline is designed as shown below:

In the Snap Settings, the Mail folder is set as INBOX and the Attachment folder is defined as Test Folder/Test Attachment Folder.

The output preview of the Snap displays the details of the image files in the email, both inline and attachments:

Downloads

  1. Download and import the Pipeline into SnapLogic.

  2. Configure Snap accounts as applicable.

  3. Provide Pipeline parameters as applicable.

  File Modified
You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.
No files shared here yet.
  • Drag and drop to upload or browse for files
  • Snap Pack History

    Release

    Snap Pack Version

    Date

    Type

    Updates

    May 2024

    main26341

    Stable

    Updated and certified against the current SnapLogic Platform release.

    February 2024

    main25112

    Stable

    Updated and certified against the current SnapLogic Platform release.

    November 2023

    main23721

    Stable

    Updated and certified against the current SnapLogic Platform release.

    August 2023

    main22460

    Stable

    Updated and certified against the current SnapLogic Platform release.

    May 2023

    main 21015

    Stable

    Upgraded with the latest SnapLogic Platform release.

    February 2023

    432patches20237

    Latest

    The JSCH library has been upgraded to version 0.2.7.

    February 2023

    main19844

    Stable

    Upgraded with the latest SnapLogic Platform release.

    November 2022

    main18944

     

    Stable

    Upgraded with the latest SnapLogic Platform release.

    August 2022

    430patches17403

    Latest

    The Email Account now does not display a null pointer exception when the Mail Properties fieldset is left blank as this is not a mandatory field. Earlier, the account displayed a null pointer exception for null values in this fieldset.

    August 2022

    main17386

    Stable

    The Email Sender Snap supports the file:/// protocol in the Attachments field.

    4.29

    main15993

     

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.28 Patch

    428patches14812

    24 Mar 2022 

    Latest

    Fixed an issue with the Email Sender Snap where SMB files were attached to an e-mail causing the Snaps to fail with a NullPointer Exception.

    4.28

    main14627

    12 Feb 2022 

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.27

    main12833

    13 Nov 2021 

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.26 Patch

    426patches11591

    21 Sep 2021 

    Latest

    Fixed the following issues with the Email Archive Snap where the Snap:

    • Failed with an error User is authenticated but not connected, as the Snap did not re-authenticate with the server after the connection expired due to the long durations in the execution of Ultra Pipelines.

    • Caused multiple copies of the same source message in the target folder when the Snap was executed multiple times in preview.

    4.26

    main11181

    14 Aug 2021 

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.25

    main9554

    08 May 2021 

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.24

    main8556

    13 Feb 2021

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.23

    main7430

    14 Nov 2020 

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.22

    422patches6730

    17 Sep 2020 

    Latest

    Fixes the connectivity issue for the Email Sender Snap by making it compatible with TLS version 1.2.

    4.22

    main6403

    12 Sep 2020 

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.21

    snapsmrc542

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.20 Patch

    email8813

    -

    Latest

    Fixes an issue with the Email Sender Snap that caused the Snap to fail while uploading attachments to SMB locations when the attachment password contained a forward slash "/".

    4.20

    snapsmrc535

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.19

    snaprsmrc528

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.18

    snapsmrc523

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.17 Patch

    ALL7402

    -

    Latest

    Pushed automatic rebuild of the latest version of each Snap Pack to SnapLogic UAT and Elastic servers.

    4.17

    snapsmrc515

    -

    Stable

    Added the Snap Execution field to all Standard-mode Snaps. In some Snaps, this field replaces the existing Execute during preview check box.

    4.16 Patch

    email6772

    -

    Latest

    Fixed an issue with the Email Delete Snap wherein the Snap fails to delete emails with multiple input documents.

    4.16

    snapsmrc508

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.15 Patch

    email6267

    -

    Latest

    Fixed an issue with handling null attachments in the Email Sender and Email Reader Snaps.

    4.15

    snapsmrc500

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.14 Patch

    email5740

    -

    Latest

    Fixed an issue with POP3 access in Email Reader, Archive, and Delete Snaps. IMAP specific methods are now not called during POP3 access.

    4.14 Patch

    email5662

    -

    Latest

    Fixed the Email Reader/Sender Snaps that replace the "+" symbol in attachment files with a space in the output.

    4.14

    snapsmrc490

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.13 Patch

    email5368

    -

    Latest

    • Enhanced Email Reader Snap to perform read and archive functions. 

    • Fixed the Email Archive Snap that does not display sorting errors. 

    • Fixed the Email Reader Snap that slows down when renaming the downloaded attachments.

    4.13

    snapsmrc486

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.12 Patch

    email4948

    -

    Latest

    Fixed an issue with the Email Reader Snap, wherein the Snap gets corrupted when a file name and content contains Unicode characters.

    4.12

    snapsmrc480

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.11 Patch

    email4481

    -

    Latest

    • Resolved an issue with Email Reader Snap:

      • The Snap now reads to fetch mails from a shared mail box.

      • The Snap can now read the file attachment that has a percent sign [%], or ó.  

    • Updated the Email Delete Snap code to display the default value as zero instead of blank in the UI.

    4.11

    snapsmrc465

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.10 Patch

    email4025

    -

    Latest

    Added Connection, Read, and Write timeout settings that support retries for SMTP, POP3, and IMAP email account types.

    4.10 Patch

    email3944

    -

    Latest

    Resolved an issue with the Email Reader Snap to support the shared mailbox on an Office 365 server. Email Reader did not support Office 365 shared mailbox until we explicitly disabled plaintext authentication when we specify ssl authentication. The Office server falsely reports that it supports PLAIN authentication and the snap library is happy to try it but it always fails. This is a known issue with Office 365 / Outlook.

    4.10

    snapsmrc414

    -

    Stable

    • Email Account Updated with Attachment password property (encrypted) to support the attachment function for the Email Sender and Reader Snaps.

    • Email Reader Snap updated with the Attachment folder property to store the attached files on a path.

    • Email Sender Snap extended support to SLDB, SFTP, and SMB file protocols for the attachments

    4.9.10

    snapsmrc405

    -

    Latest

    Upgraded with the latest SnapLogic Platform release.

    4.8.0 Patch

    email2816

    -

    Latest

    Addressed an issue with Email Sender Snap being unable to Handle Chinese characters.

    4.8

    -

    -

    Stable

    Upgraded with the latest SnapLogic Platform release.

    4.7.0 Patch

    email2499

    -

    Latest

    Added logic to process emails that have text files as attachments and download the files to the provided attachment location.

    4.6.0

    snapsmrc362

    -

    Latest

    • Resolved an issue in Email Sender Snap that failed when attached a file that had spaces in the file name.

    • Enhanced error handling in Email Reader Snap to appropriately route connection errors to error view.

    4.5.1

    email1564

    -

    Latest

    • BCC field added to the Email Sender Snap.

    • Retries added to the Email Sender Snap.

    -

    -

    August 7, 2015 (2015.25/4.2.1)

    -

    • Email Reader Snap now has an option to read older message first.

    • Resolved Null Pointer exception in Email Reader Snap when reading from Yahoo mailbox.

    -

    -

    June 27, 2015 (2015.22)

    -

    Email Sender now supports the ability to pass through input documents.

    -

    -

    June 6, 2015 (2015.20)

    -

    Email Reader: Resolved an error with concatenating file names in attachments

    -

    -

    Snap Updates, December 20, 2014

    -

    NEW! Email Archive introduced in this release.

    -

    -

    November 2014 Launch Updates

    -

    NEW! Email Delete Snap was introduced in this release.

    -

    -

    October 18, 2014

    -

    Email Sender now allows JSONPath expressions

    -

    -

    Fall 2014 Launch Updates

    -

    Email Sender: better handling of error messages to the error view.

    -

    -

    December 2013 Launch Updates

    -

    Email Reader Snap and Email Sender Snap were updated to handle attachments.

    -

    -

    September 2013 Updates

    -

    Email Sender & Email Reader introduced in this release. This pair of Snaps let you send and receive an email when you run a pipeline.

    Updated and certified against the current SnapLogic Platform release.

    • No labels