Connect to Exchange Email Server

Connects to an Exchange 🡥 email server, storing the established connection in a variable.

Command availability: IBM RPA SaaS and IBM RPA on premises

⚠ Attention: The Connect to Exchange Email Server command (exchangeConnect) is deprecated. See the Deprecated and removed functions for more details.

Description

Connects to an Exchange 🡥 email server, storing the established connection in a variable. The command searches emails through all folders. To specify a folder, use the Apply Search Filters (emailApplySearchFilters) command.

Exchange connections can access multiple shared mailboxes at once, including the default mailbox of the account that is bound to the connection in the IBM RPA Control Center. You must use the Apply Search Filters (emailApplySearchFilter) command and enter the shared mailboxes emails in a List<text> variable in the Search in Mailboxes (N/A for IMAP) parameter.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

exchangeConnect --exchangeversion(Nullable<AutomationExchangeVersion>) [--exchangeurl(String)] [--username(String)] --mailusername(String) [--mailpassword(String)] [--enableLog(Boolean)] (EmailConnection)=value

Dependencies

  • If you are using the IntegrationConnection authentication type, refer to Connections.

  • If you want to access shared mailboxes that your account has access to, you must use the Apply Search Filters (emailApplySearchFilter) command and enter them in a List<text> variable in the Search in Mailboxes (N/A for IMAP) parameter.

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Exchange Version exchangeversion Required AutomationExchangeVersion Exchange server version options to use.
Exchange URL exchangeurl Optional Text Exchange email server address.
Authentication Type authenticationtype Required Text The type of authentication. See the authenticationType parameter options.
Connection connection Required when the authentication type parameter is IntegrationConnection text Connections available in your tenant.
Username username Optional Text Username registered on the Exchange server.

🛈 Remember: Usually, this is the email address of the account registered on the server hosting the Exchange service.
email mailusername Required Text User's email address to connect to the server.
Password mailpassword Optional Text User's email password to connect to the server.
Enable Log enableLog Optional Boolean Enables protocol logging, if available.

The %localappdata%\IBM Robotic Process Automation directory stores the log file.

authenticationType parameter options

The following table displays the options available for the authenticationType input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
BasicAuthentication basicAuthentication Uses basic authentication to authenticate third-party accounts. Requires User name and password.
IntegrationConnection integrationConnection Uses Oauth authenticated connections from the tenant you're logged in.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Connection value Email Connection Collection containing all messages from the account's email boxes.

Examples

Example 1: Connects to the Exchange mail server.

defVar --name exchangeConnection --type EmailConnection
// Connect to the Exchange 2013 server.
exchangeConnect --exchangeversion "Exchange2013" --exchangeurl "mail.exchangecorp.com.br" --username "useremail@email.com" --mailusername "useremail@email.com" --mailpassword userpassword --enableLog
// Disconnect from the server.
emailDisconnect --connection ${exchangeConnection}

Example 2: Connects to the Exchange mail server and apply a filter to search for emails only in the Spam folder.

defVar --name exchangeConnection --type EmailConnection
defVar --name outputConnection --type EmailConnection
defVar --name spamFolder --type String --value Spam
// Connect to the Exchange 2013 server.
exchangeConnect --exchangeversion "Exchange2013" --exchangeurl "mail.exchangecorp.com.br" --username "useremail@email.com" --mailusername "useremail@email.com" --mailpassword userpassword --enableLog 
//Apply a filter to search emails only in the Spam folder.
emailApplySearchFilters --useanotherfolder  --folderpath "${spamFolder}" --subjectdirective "All" --wordsdirective "All" --connection ${exchangeConnection}
// Disconnect from the server.
emailDisconnect --connection ${exchangeConnection}

🛈 Remember: The previous examples are only illustrative, so for it to work, you must enter a valid IMAP connection and its appropriate settings.

Limitations

  • You must get the port, username, and password data from your email provider. If you leave the Exchange URL parameter empty, the command uses the autodiscover 🡥 service to get the Exchange URL data.

  • To send emails the connection must use the original email account and not an alias. Connections using an aliased email account can only read emails.