This repository contains flows and subtasks poll an IMAP Email Server for emails and to process each received email asynchronously in a separate flow
This is the main flow to retrieve emails from an email IMAP server
- i_config-area: The name of an area in the CTX-Configuration-Store containing the following configuration parameters:
- Server: The FQDN of the IMAP server
- Port: The port on the server to which Cortex must connect (Optional - defaults to 993)
- Timeout: The timeout in seconds before an attempt to connect to the server fails; a value of 0 means do not timeout (Optional - defaults to 0)
- Secure-Connection Specifies whether Transport Layer Security (TLS) is enabled for the IMAP connection (Optional - defaults to true)
- Username: The email account username
- Password: The email account password
- In-Folder: The name of the folder containing emails to be processed by Cortex (Optional - defaults to Inbox)
- Retrieved-Folder: The name of the folder into which emails downloaded by Cortex are moved before they are processed (Optional - defaults to Retrieved)
- Processed-Folder: The name of the folder into which emails downloaded by Cortex are moved after they are processed (Optional - defaults to Processed)
- Attachment-Folder: The name of a folder (directory) on the Cortex server to which email attachments are saved; all attachments in a single email are saved to the same, unique folder
For each unread email in the In-Folder folder of the mainbox, Cortex will:
- Download the email
- Move the email to the Processed folder
- Asynchronously execute an instance of the CTX-Email-Process-Email flow
This flow is exected to process a single email message. The flow will:
- downloads any attachments to the Attachment-Folder/flow-UUID on the Cortex Server; this folder (directory) will be created if it does not exist
- determines how to handle the email
- if the email is successfully processed, moves the email to the Processed-Folder on the IMAP server (otherwise it is left in the Retrived-Folder)
To process emails, modify the process-Email state of the flow. Inspect the email information contained in the g_Message structure to determine how to process the email. Set the g_Processed boolean parameter to true if the email has been processed successfully.
It may be easier to perform the processing in another synchronously executed flow; this flow should accept the g_Message structure parameter as an input parameter, and return the g_processed boolean parameter as a return parameter.
Download the Studio Package file and Import it into your Cortex Environment. Don't forget to apply rights using the Studio Authorization module.
This library depends upon the following libraries:
👍 Enjoy! 😉