◷ Reading Time: 4 minutes


Allows communication to Mail Servers using IMAP and EWS protocols.


Connects to mail server.

 mailBox (serverAddress, options)
  • serverAddress (string): Combination of server address and port with the following format Address:Port
  • options (object): A set of options
    • user
    • password
    • useSsl
    • acceptAllCertificates
    • protocol


mail = mailBox  ('',  
                 {user:'', password:'123123'}


Allows querying mail messages on the mail server.

 |mailQuery (queries)

Below is list of queries that can be used:

  • delivered after(date)
  • delivered before(date)
  • delivered on(date)
  • sent after(date)
  • sent before(date)
  • sent on(date)
  • not delivered after(date)
  • not delivered before(date)
  • not delivered on(date)
  • not sent after(date)
  • not sent before(date)
  • not sent on(date)
  • field to contains(value)
  • field to not contains(value)
  • field from contains(value)
  • field from not contains(value)
  • field bcc contains(value)
  • field bcc not contains(value)
  • field cc contains(value)
  • field cc not contains(value)
  • field subject contains(value)
  • field subject not contains(value)
  • header contains(value)
  • header not contains(value)
  • message contains(value)
  • message not contains(value)
  • body contains(value)
  • body not contains(value)
  • seen
  • not seen

Not all the queries are supported with all the mail servers.


messages = mail|mailQuery (field subject contains('connecting to arash') and                            
                           field from contains('arash') or
                           not sent before(#1/1/2008#)  

Mail Message

There are operators that can be run on each individual mail message.


Delete a message

 .Delete (permanent)
  • permanent: Boolean value i.e. true or false
 Example: msg .Delete (true)   


Mark a message as read or unread

 .MarkSeen (seen)


Forward a message to a list of recipients

 .Forward (text, to, cc, bcc, smtpOptions)
  • text (string): Optional text to prefix the message before forwarding
  • to (string or array): List of receivers email address (i.e. [‘’] or individual email address (Mandatory)
  • cc (string or array): Optional list of received or individual email address
  • bcc (string or array): Optional list of received or individual email address
  • smtpOptions: An object that represents SMTP options to be used as a client to send messages (IMAP protocol requires)
    • Server: SMTP address
    • Port: SMTP port
    • UseSsl: true/false
    • user: user name if authentication is required
    • password: password to authenticate against the SMTP server

MailBox Expression Builder

With MailBox extension, a tool will be installed that allows you to build expressions easily.

Connection Builder

The below form allows you to create ‘mailBox’ expression:

Query Builder

The below form allows you to create ‘mailQuery’ expression:


Updated on May 11, 2022

Was this article helpful?

Related Articles