Task Messaging - Email - Get Messages
The Email - Get messages Task reads the messages in a mail folder that match its conditions and attachment filter, using a POP3, IMAP4, Exchange EWS, Exchange WebDAV or Microsoft Graph API Connection. It can save each message and its attachments to disk, mark it as read or delete it on the server, and it writes one line per message to the output.
The Main settings, Flow, On error, Conditions and TimeOut tabs are the same for every Task; see Job - Tasks.
Email - Get messages: Main settings tab

-
Connection: the Connection to the mailbox, of one of these types: Connection - POP3, Connection - IMAP4, Connection - Exchange EWS, Connection - Exchange WebDAV or Connection - Microsoft Graph API
-
Mail folder: the folder to read
- Use default folder (default): the default folder of the mailbox, the Inbox
- Use specified folder: type the folder path, or click the folder button to choose it from the server. Choosing is not possible with POP3, and with POP3 the setting is ignored. If the folder does not exist, the Task fails with the error
Folder "<name>" not found - Is public folder: select it when the specified folder is an Exchange public folder. It is applied with Exchange EWS and Microsoft Graph API Connections only
-
Message on Server: what happens on the server to each message that the Task reads
- Leave message on Server (default): the message is not deleted. It is marked as read if Mark as read (not POP3) is selected
- Mark as read (not POP3): marks the message as read. It has no effect with POP3
- Delete message on Server: deletes the message
If Mark as read (not POP3) is selected, the message is only marked as read, even when Delete message on Server is selected. Clear Mark as read (not POP3) to delete.
With Delete message on Server, the message is deleted even when an attachment was not saved: for example, when a file with the same name exists and neither Overwrite existing nor Expand existing file name is selected, or when saving fails. To keep such messages, select Expand existing file name or Overwrite existing, or leave the messages on the server and delete them in a later Task.
Before you select Delete message on Server, check which messages match with the Email - Get messages: Test tab, or with an Email - Get headers Task that uses the same Connection, folder and conditions. With IMAP4 and Exchange WebDAV Connections, From address conditions select more messages than their names say; see the Email - Get messages: Conditions tab.
- Decryption by...: Certificate is the certificate that decrypts encrypted messages; see Global - Certificates
When a certificate is selected, an encrypted message that it decrypts is skipped: it is not saved, marked or deleted, and nothing is written to the output. An encrypted message that it cannot decrypt is skipped too. So with a certificate selected, this Task cannot save or delete encrypted messages. When no certificate is selected, or the selected certificate has been removed from Global - Certificates, an encrypted message is processed as it is, still encrypted, and can be saved, marked or deleted.
- Save email: what is saved to disk for each message
- Save email: saves the whole message as an .eml file named after its ID. An existing file of that name is replaced
- Save attachment(s): saves the attachments that match the Email - Get messages: Attachment filter tab
- Overwrite existing: replaces an attachment file of the same name. Enabled with Save attachment(s). If neither this nor Expand existing file name is selected, an existing file is kept and the attachment is not saved
- Expand existing file name: when a file of the same name exists, adds a number to the new name, for example
report1.pdf. Enabled with Save attachment(s) - Save to default folder (default): saves under
<VisualCron installation folder>\data\email\ - Save to folder: saves under the folder you type. Credential is used to access this folder, and only this folder
- Create folder tree based on each email: selected by default. Each message gets a folder named after its ID: the message is saved as
<ID>\<ID>.eml, and its attachments in<ID>\attachments\. When cleared, all files are saved directly in the folder
In folder and file names, characters of the mail ID that are not allowed in file names are replaced with the Unicode replacement character, U+FFFD (�). To get the same name in another Task, apply the Variable function Encode FileName (replace invalid chars with: provided masking string / empty string / unicode equivalents) under File variables to the mail ID: {PATH(EncodeFileName|<mail ID>|MASK)}. MASK replaces each character that is not allowed with U+FFFD.
Email - Get messages: Conditions tab
The fields and limits are the same as on the Conditions tab of Task Messaging - Email - Get Headers. A message is read only when it matches every condition that is set.
With IMAP4 and Exchange WebDAV Connections, every From address condition acts as "Contains (=%)". "Not equal (!=)" and "Not contains (!=%)" select the messages from that address instead of excluding them, and "Equal (=)" also matches longer addresses that contain the value. With Delete message on Server, those messages are deleted. With POP3, Exchange EWS and Microsoft Graph API Connections, From address is applied as set.
Email - Get messages: Attachment filter tab
The fields are the same as on the Attachment filter tab of Task Messaging - Email - Get Headers. When File mask is not *, or a size check is selected, a message is read only when at least one attachment matches, and only the matching attachments are saved.
If both size checks are selected, the value of Check if file is smaller than x size is treated as 0, so with "AND" no attachment matches. Select only one size check.
Email - Get messages: Test tab
Show filtered messages runs the current settings on the Server and shows the result. Number lines in the result limits how many lines are shown. The test does not save, mark or delete any message.
Output tab
The fields are the same as on the Output tab of Task Messaging - Email - Get Headers, and Body can also be chosen. Each line holds the fields chosen in Show mail headers. The paths of saved files are not written to the output. When Include field names is selected together with Save email or Save attachment(s), the output starts with "Email file path" and "Attachment file path(s)" instead of the field names, joined to the first line with no line break.
Output and errors
- When no message matches, the output is empty, and the Task succeeds
- If a message cannot be downloaded from the server, the Task stops with an error. Messages handled before it stay saved, marked or deleted
- If the Connection is missing, the Task fails with "Connection not found". If the specified folder does not exist, it fails with the error
Folder "<name>" not found(the "No folder(s) found" cause on the On error tab)
If an attachment cannot be saved, the error is written to the Server log, the message is still marked or deleted as selected, and the Task reports success.
If an attachment is not saved because a file of the same name exists and neither Overwrite existing nor Expand existing file name is selected, no error is raised, the message is still marked or deleted as selected, and the Task reports success.
If the .eml file of a message cannot be saved, or the message cannot be deleted on the server, the error is written to the Server log, the Task goes on with the next message, and the Task reports success. A message whose .eml file was not saved is not marked or deleted, and no line is written for it.
If a message cannot be marked as read, the error is written to the Server log, the message stays unread, and the Task reports success.