Online Documents
English
English
  • First Launch Experience
  • Activate Software License
  • How to Train EMILY?
  • Simple Web Automation
  • Web Automation Tools
  • Web Automation Processor
  • User Fill
  • Workspace Script
  • File Exporter
  • File Enumerator
  • EXCEL Processor
  • EXCEL Analyzer
  • EXCEL Writer
  • EXCEL Filler
  • CSV Creator
  • PowerShell
  • PDF Analyzer
  • Mail Sender
  • Mail Reader
  • Exchange Mail Sender
  • Exchange Mail Reader
  • HTTP Analyzer
  • Command Line
  • DOCX Templater
  • SQL Executor
  • Desktop Automation (DA)
  • SFTP
  • JSON API Server
  • Chart
  • DOCX2HTML
  • Manage Folder
  • Google Drive
  • Google Sheets
  • Google OCR
  • Google NLU
  • Azure Form Recognizer
  • Anti-Captcha
  • ChatGPT
  • Gemini
  • Schedule Trigger
  • Mail Trigger
  • File Trigger
  • API Trigger
  • Protect Text
  • Flexibility & Security
  • Announcements
    • Version Release
    • Third Party Notice
Powered by GitBook
On this page
  • HOST
  • PORT
  • TLS/SSL
  • USERNAME
  • PASSWORD
  • MAILBOX
  • SINCE DAY(S) AGO
  • UNREAD ONLY
  • Input Object
  • Output Object
  • API

Mail Reader

Read email via IMAP

PreviousMail SenderNextExchange Mail Sender

Last updated 1 month ago

HOST

IMAP mail server hostname, such as imap.gmail.com.

PORT

IMAP mail server port number, typically set to 993.

TLS/SSL

Whether the IMAP mail server requires TLS/SSL encryption.

USERNAME

The user name configured in the email server. The %FILENAME% variable can be included to insert the content of the TXT file with the filename named 'FILENAME' inside the workspace, achieving dynamic customization.

PASSWORD

Password for the account filled above. The %FILENAME% variable is also supported

MAILBOX

Mailbox name.

SINCE DAY(S) AGO

Read emails since how many days ago.

UNREAD ONLY

Choose whether to read unread emails only.

Input Object

Each element in the input object array represents each email read from the specified mailbox:

// Print the subject and sender of each email read
input.forEach((mail) => {
  console.log('from:' + mail.from + ', title:' + mail.subject)
})

Output Object

Each object added to the output array represents a row of data in the output table. The object contains key-value pairs, where the key is the column header, and the value is the data for that column in the row. Once all the data is processed, the table will be output as a .csv file called 'output.csv' in the workspace.

// Output each text field from the read emails to a CSV and save attachment files.
input.forEach((mail) => {
  output.push({
    from: mail.from,
    subject: mail.subject,
    date: mail.date.toLocaleString(),
  })
  
  if (mail.attachments.length > 0) {
    mail.attachments.forEach((att) => {
      api.write(att.filename, att.content)
    })
  }
})

// Specify the header field
output.header.push('from','subject','date')

API

Sychronous APIs are provided: api.files(), api.read(filename, encoding='utf8'), api.write(filename, text), api.rename(oldname, newname), api.remove(filename) to access files in workspace; and asynchronous APIs api.mail.moveto(uid, mailbox) and api.mail.remove(uid) are provided to mange mails.

// find mail with subject containing 'promote'
let mail = _.find(input, (m) => m.subject.includes('promote'))

// move the mail to 'Trash' mailbox
await api.mail.moveto(mail.uid, 'Trash')

// find mail with subject containing prize
mail = _.find(input, (m) => m.subject.includes('prize'))

// remove the mail
await api.mail.remove(mail.uid)

We are dedicated to improving our content. Please let us know if you come across any errors, including spelling, grammar, or other mistakes, as your is valuable to us! 🤖️⚡️

feedback