E-mail tasks: automatic processing of attachments

How to set up a task that regularly collects e-mails from a mailbox folder, processes the attachments and saves them to the chosen company's storage.

An e-mail task watches a given folder of a mailbox, handles the attachments of incoming e-mails with the chosen processor (for example just storing them or linking them to invoices) and saves them to the company's Drive folder or to local storage. Processed e-mails are moved to the processed folder, so nothing is taken in twice.

Before you start

  • Have the mailbox login ready: a Gmail account, an IMAP host with user name and password, or an MS365 tenant ID, client ID and client secret.
  • For Google Drive storage the company needs a configured storage account.

A new task step by step

  1. Open System → Email tasks and click the blue + button at the top right.
  2. Fill in Name and Code and set Status to active.
  3. In the Mail source block choose the Source, then fill in its fields (Gmail: Gmail account, Mailbox folder (Gmail label); IMAP: IMAP host, Port, Encryption, IMAP username, IMAP password, Watched folder; MS365: Tenant ID, Client ID, Client secret, Mailbox (user)). Load folders lists the mailbox folders.
  4. Enter the Processed folder and, if needed, the Error folder.
  5. You can narrow the e-mails: Sender filter (from), Recipient filter (to), Subject filter, Attachment pattern (regex); for compressed attachments fill in Archive password.
  6. Choose the Handler (processing adapter).
  7. Choose Client company, Target storage (Google Drive or Local storage), Storage account and Target folder. Create a new folder with New folder and Create folder.
  8. In the Schedule block set Repeat, Start at (hour : minute) and, for minute-based repetition, Interval (minutes).
  9. Click Save. The system creates or updates the schedule in the scheduler list by itself.
  10. To try it, click the row's Run now icon; the result appears under Recent runs.

Rules and messages

  • The code is 2–32 characters (lower-case letters, digits, underscore, hyphen) and must be unique: "Warning: This code is already used by another email task!"
  • The processed folder is required because it is the protection against processing twice.
  • The IMAP password and the MS365 client secret are only required for a new task; left empty later, the old one stays.
  • For minute-based scheduling the interval is 5 to 1440 minutes; weekly schedules take a weekday, monthly ones day 1–28.
  • An inactive task cannot run: "Warning: The task is inactive — activate it before running!"
  • If a manual run does not fit into a few seconds, the rest continues automatically in the background.

For an inactive task, without a target company or with a wrong interval, the schedule is switched off. Deleting a task also deletes its schedule.

Example

Sample Ltd. receives supplier invoices on the "Invoices" label of a shared mailbox. They add a task with Gmail as source, the "Invoices" folder, "Processed" as processed folder, Sample Ltd.'s Drive folder as target storage and an hourly schedule. After the first Run now, Recent runs shows 4 attachments matched and 4 processed.