Count Emails
Counts emails from the connected server's inbox.
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
Counts emails from the connected server's inbox.
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.
emailCount --connection(EmailConnection) (Numeric)=value
Dependencies
-
Use the For Each (
forEach
) command to get email message instances. Otherwise, the command will only return the first result. -
Use the following commands to connect to an email server:
- Connect to Exchange Email Server (
exchangeConnect
) - Connect to IMAP Email Server (
imapConnect
) - Connect to Microsoft Outlook (
microsoftMailConnect
)
- Connect to Exchange Email Server (
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 |
---|---|---|---|---|
Connection | connection |
Required |
Email Connection |
Variable that holds the established email connection. |
Output parameters
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Quantity | value |
Number |
Returns the number of emails from the inbox. |
Example
After the connection to an IMAP server is established, the command counts the emails from the inbox.
defVar --name emailConnection --type EmailConnection
defVar --name emailQuantity --type Numeric
imapConnect --mailhost "outlook.office365.com" --mailport 993 --usessl--username "useremail@email.com" --mailusername "useremail@email.com" --mailpassword userpassword --enableLogemailConnection=value
emailCount --connection ${emailConnection} emailQuantity=value
logMessage --message "${emailQuantity}" --type "Info"
// emailQuantity: 50