Email Reader

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.



Prerequisites

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

Note:

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.

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.

Snap views

View Description Examples of upstream and downstream Snaps
Input

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 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: "[email protected]", to: "[email protected]; [email protected]", cc: "[email protected]", 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 when 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 an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining 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

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Email Reader

Example: Email Reader
Mail folder String/Expression/ Suggestion

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

Important: 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.

Default value: Inbox

Example: Inbox
Unread only Checkbox

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.

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

Default status: Deselected

Number of messages Integer

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

Default value: All

Example: 100
Older message first Checkbox

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.

Default status: Deselected

Attachment folder String/Expression

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

Warning:
  • This property is expression-enabled. For more information on the expression language, see Understanding Expressions in SnapLogic and Using Expressions.

  • 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:

Default value: Shared

Example: smb://<username>@<hostname>:<port>/<directory>
File action Dropdown list 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.

Default value: OVERWRITE

Example: RENAME

Archive messages after reading Checkbox 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.

Default status: Deselected

Target folder String/Expression/ 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.

Important: 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.

Default value: None.

Example: Archived

Snap execution Dropdown list
Choose 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.

Default value: Execute only

Default value: Validate & Execute

Examples