ReadEmail

The ReadEmail function will connect to a mail server using either IMAP or POP3.

IMAP (Internet Message Access Protocol) provides access and retrieve mail functions for a remote mail server so the mails can be used locally while retaining them also on the server. Imap sets message flags so that the user can keep track of which messages he or she has already seen, already answered, and so on.

POP (Post Office Protocol) implements the offline mail access model, where mail is retrieved and then deleted from the server where the mailbox resides so it can be used on a local machine. Emails are hence transferred permanently from a central server to one client machine.

Properties

Mail server settings

Protocol

Protocol to use when reading the email.

Authentication

The type of authentication needs to be one that the mail server is capable of.

User name

The user name for the mailbox you wish to access.

Password

The password for the mailbox you wish to access.

Port

The port number used to access the mailbox.

Server name

The IP address, URL or network name of the server.

Use SSL

Using SSL (Secure Socket Layer) is more secure as the data is encrypted.

Options

Folder

The email folder on the server where the mails you wish to retrieve are stored (IMAP only).

Only unread items

A flag to indicate whether only unread mails should be retrieved (IMAP only).

Mark as read

A flag to indicate whether retrieved emails should be marked as 'read' (IMAP only).

Move to folder

A folder to move retrieved emails to (IMAP only).

Delete after read

A flag to indicate whether retrieved emails should be deleted from the original folder.

Body as HTML

A flag to indicate if the email's body should be retrieved formatted in HTML. Otherwise, the body will be retrieved as unformatted text.

Attachment options

Three actions are available for attachments.

None will ignore attachments.

SaveToFile will save the attachments as files to the specified directory. The filepath is an automatic output of this function and can be used to use an attachment later in the process.

ReturnData will convert the attachment contents to a string or a List and allow you to use that further down in your process. This option will require you to set the Attachment data property.

Attachment data

This property will only display if ReturnData was selected for the Attachment options property.

Select either Text or Binary, depending on the type of data.

Text returns a String and Binary returns a List<byte>.

Save email

A flag to indicate if the emails should be saved to disk.

File directory

The directory where emails and attachments will be saved. For emails, the subject line becomes the filename. Attachments already have filenames that will be used when saving.

If a file of that name already exists, the function will add the year, month, day, hour, second and milliseconds to the filename in this format yyyy-mm-dd-hh-ss-ffff to make sure it is unique.

If the filename is too long, it will be truncated.

Email file type

The file type used when saving emails to disk.

Regex filters

Regex filters allow you to retrieve emails containing specific information.

The regular expression matching is case sensitive by default. Use the case insensitive mode modifier (?i) to force case insensitive matching.

Filter body

Text to search for in the body of the email.

Filter from

Text to search for in the display name of the sender of the email.

Filter from address

Text to search for in the address of the sender of the email.

Filter subject

Text to search for in the subject of the email.

Filter to

Text to search for in the recipient of the email.

Filter cc

Text to search for in the cc recipients of the email.

Regex filters operator

Filter option

If you have specified multiple RegEx search criteria, you can define whether these should be chained together with an AND or with an OR. AND means that all filters need to be true for the mail to be retrieved. OR means that ANY of the filters need to be true for the mail to be retrieved.


Reading Gmail emails

For email providers using two-factor authentication (such as Gmail), you will need to complete additional steps to bypass further security settings.

To set up your Gmail account for use by your Linx applications, there are 2 options:

1. Allow less secure apps

In your Gmail account:

  • Select Sign-in and Security

  • Switch off 2-Step verification

  • Scroll down and set “Allow less secure apps” to “On”

OR

2. Create an App password

(This is the recommended option.)

Go to the Google Account section:

  • Select Security

  • Make sure 2-Step Verification is switched 'On'

  • Select App passwords

  • Verify yourself

  • Select 'Other'

  • Provide a name (e.g. Linx)

  • Click Generate

  • The password that you have to use in Linx will display

Note: After setting up your App password, you can switch 2-Step Verification 'Off' again.


In Linx Designer

Set the following properties:

  • Protocol: Imap

  • Enable SSL

  • Port 993

  • SMTP server: imap.gmail.com


Linx Community: Email plugin configuration

Linx Community: Email filtering

Wikipedia: IMAP

Wikipedia: POP3

Wikipedia: Regular expression

Regular expression mode modifiers