Email package

The Email package contains actions to automate email-related tasks through Exchange Web Services (EWS), Microsoft Outlook, and other email servers. You can use these actions for sending, receiving, and modifying messages, folders, and the status of messages.

Note:
  • The Email package supports the email automation of a shared mailbox in Outlook for Office 365/Microsoft 365 using IMAP/EWS protocols, and OAuth 2.0 authentication using Client Credentials and Authorization Code with PKCE grant flows. You can automate emails retrieved from a shared mailbox and perform email-related tasks by accessing each folder(s) and its subfolder(s) in the shared mailbox. Ensure that you have set up the shared mailbox in your Outlook application. Note that sending, forwarding, and replying to emails using a shared mailbox is not supported.
  • Proxy is supported for EWS OAuth 2.0. When you create a bot that uses EWS OAuth2 for authentication and the Bot Runner machine is configured behind the firewall, then all outbound requests are routed through the proxy server configured on the Bot Runner machine.
  • When you read emails in a loop using a Microsoft Outlook Client connection with a subject filter, the bot cannot read undelivered emails, if the subject contains these receipts:
    • Delivery receipt
    • Read receipt
    • Undelivered receipt
    Outlook client does not support this feature due to the third-party library it uses.

    We recommend that you use Email server > IMAP to connect, read and filter such emails.

The Email package supports EWS, POP3, SMTP, and IMAP protocols and enables you to perform the following tasks:
  • Manage and organize email messages and folders.
  • Download attachments from emails to specific folders on devices.
  • Extract data from emails to variables, to use as extracted data in other applications. For example, you can extract data from a sender's email and store it in a Microsoft Excel spreadsheet.
Note: If you want to automate an email-related task on a device using Microsoft Outlook, ensure that the Outlook application is open.
Note:
  • If your current office installation is any of the following:
    • Microsoft 365 Apps for Enterprise
    • Office 2016, 2019, or 2021 (Consumer Version 2009 or later)

    Then you do not need to install the Microsoft Access Database Engine as an additional component in your system.

    However, if you have both Microsoft 365 Apps and the Microsoft Access Database Engine are installed on your system, then you can uninstall the Microsoft Access Database Engine and repair Microsoft 365 Apps.

    Microsoft recommends that you do not install the Microsoft Access Database Engine driver separately because both the Microsoft Access Database Engine 2016 and Microsoft 365 Apps use the same major version identifier (16.0). To learn more about the Microsoft Access Database Engine driver installation requirement, see Unable to use the Access ODBC or OLEDB provider

  • When you send an email, reply, or forward, the attachment size allowed in the email depends on your internet speed (timeout of 120 seconds) and the email server restrictions. If sending an attachment takes more than 120 seconds, the system displays an error due to timeout.

Considerations

Note: Some of the actions must be used within a Loop action. See Using the For each mail in mail box iterator.
Emails are retrieved based on the sequence of the folders listed in the inbox field. Within each folder, emails are retrieved based on received date and time in the last in, first out (LIFO) order. Additionally, you can apply filters on the following fields:
  • Types of emails: All, Read, and Unread
  • Subject
  • From a specific folder
  • From specific sender
  • Before, on, or after received date
Adhere to the following best practices when you filter and loop through folders that contain a large number of email messages:
  • After you have processed email messages, move them to another folder so that their duplicate email messages are not processed again during a subsequent run.
  • Try to reduce the number of messages in the mailbox.
  • The filtration works on the filter parameters provided by the user, such as type of email: All, Read, and Unread; Subject; from a specific folder; from a specific sender; or before, on, or after received date). Following are the types of filter mechanisms:
    • Email server-side: The filtration that takes place on the server-side is much faster.
    • Client-side: Filtration is performed on the local machine and is comparatively slow because the mail messages are first retrieved from the remote server and then filtered in the local machine.
    • Hybrid: Some parameters are filtered on the server side and some on the client side.
  • Here is an explanation of how the filtration process works for various server types:
    • EWS: All filtration is done on the server side and is hence much faster.
    • Outlook client: Nothing is filtered on the server side, but the filtration process is faster because email messages are already present on the local machine.
    • IMAP: Filtration for the Subject field is performed on the local machine and is slower. For the Before, on, or after received date parameter, the filtration for date is performed on the remote server, and for hour/min/second, it is performed on the local machine. For example, for the date 01/12/2022, filtration is performed on the remote server whereas for the time (hour/min/sec) 21:10:56, filtration is performed on the local machine.
    • POP3: This server is the slowest of all because mails are retrieved from the remote server, and filtration is done in the local machine.

    We recommend connecting using the EWS server and Outlook client as the filtration process is much faster when compared to IMAP and POP3 protocols.

  • Always use the Disconnect action if the Connect action is used to release a resource.

Before you start

Perform the following actions within the Email package as part of using the set of available actions:

  1. Establish a connection with an email server using the Connect action.

    While establishing the connection, specify the details and session name of the email server. Use this same session name for the other actions.

    You do not have to establish a connection for the Forward, Reply, and Send actions because you will add the sender and email server details when you use these actions.

  2. Use the actions to automate a task.
  3. After you have automated all the email-related tasks, terminate the connection to the mail server using the Disconnect action.
Important: You must enable POP settings to automate an email-related task on the Gmail server using the POP3 protocol. See Read Gmail messages using POP.

Actions in the Email package

The Email package includes the following actions:

Action Description
Change status See Change status action.
Check if folder exists See Check if folder exists action.
Delete all See Delete all action.
Delete See Delete action.
Disconnect See Disconnect action.
Connect See Using Connect action in Email package.
Forward See Using Forward action.
Move all See Move all action.
Move See Move action.
Reply All See Reply All action.
Reply See Using Reply action.
Save all attachments See Save all attachments action.
Save attachments See Save attachment action.
Save email See Save email action.
Send See Using Send action.

Resources

The following learning courses from Automation Anywhere University: RPA Training and Certification (A-People login required) explain how to use an Email package to automate email-related tasks: