Send Email

Sends an email message.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Sends an email message.

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.

emailSend --connection(EmailConnection) --to(List<String>) [--from(String)] [--cc(List<String>)] [--bcc(List<String>)] [--subject(String)] [--bodytype(BodyType)] --body(String) [--attachments(List<String>)] [--headers(StringDictionary<Variant>)] [--labels(List<String>)]

Dependencies

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.
To to Required List<Text> List that holds the email address of the recipient.
From from Optional Text List with the sender's email address. Some email providers, like Microsoft Exchange, require that you set this parameter.
Cc cc Optional List<Text> List with email addresses of the recipients that should receive a copy of the message.
Bcc bcc Optional List<Text> List with email addresses of the recipients that should receive a blind copy of the message.
Subject subject Optional Text Subject of the email message.
Body Type bodytype Optional BodyType Type of text that will make up the body of the email message.

See the bodytype parameter options.
Email Body body Required Text Text that will make up the body of the email message, according to the type of formatting specified in the Body Type parameter.
Attachments attachments Optional List<Text> List with the path of the files that will be attached to the email message.
Headers headers Optional String Dictionary<Any> Key and value referring to the information about the message to be sent, as sender, recipient and server, or any other information that needs to be attached to the header.
Categories labels Optional List<Text> Category External link of the classification of the email message.

bodytype parameter options

The following table displays the options available for the bodytype 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
Html Html Text in html format.
Rtf Rtf Text in rtf format.
Text Text Plain text.

Example

Example 1: Sending a plain text email message to one recipient, with copy and blind copy to others, from the connection to the Google server.

defVar --name connection --type EmailConnection
defVar --name destinataryList --type List --innertype String --value "[user1@gmail.com,user2@hotmail.com]"
defVar --name cc --type List --innertype String --value "[user3@gmail.com,user@outlook.com]"
defVar --name bcc --type List --innertype String --value "[user5@hotmail.com]"
defVar --name category --type List --innertype String --value "[main]"
// Connect to the SMTP email server to send the message.
smtpConnect --smtphost "smtp.gmail.com" --smtpport 465 --smtpusername "useremail@gmail.com" --smtppassword userpassword --smtpusesslconnection=value
emailSend --connection ${connection} --to ${destinataryList} --from "useremail@gmail.com" --cc ${cc} --bcc ${bcc} --subject "Sending email in plain text" --bodytype "Html" --body "Good Morning!\r\nWould you like to make a reservation, which day is available?" --labels ${category}

Example 2: After connecting to an SMTP email server, an email message in HTML format is sent to one recipient, with copy and blind copy for others.

defVar --name connection --type EmailConnection
defVar --name destinataryList --type List --innertype String --value "[user1@gmail.com,user2@hotmail.com]"
defVar --name cc --type List --innertype String --value "[user3@gmail.com,user@outlook.com]"
defVar --name bcc --type List --innertype String --value "[user5@hotmail.com]"
defVar --name category --type List --innertype String --value "[principal]"
// Connect to the SMTP email server to send the message.
smtpConnect --smtphost "smtp.gmail.com" --smtpport 465 --smtpusername "useremail@gmail.com" --smtppassword userpassword --smtpusesslconnection=value
emailSend --connection ${connection} --to ${destinataryList} --from "useremail@gmail.com" --cc ${cc} --bcc ${bcc} --subject "Sending email in HTML format" --bodytype "Html" --body "<p><strong>Good Morning!</strong></p>\r\n<p>I would like to make a <em>reservation</em>, what days are available?</p>" --labels ${category}

Note: Use a valid email connection to run this example script.