Connect to SMTP Server
Connects to an SMTP email server, storing the established connection in a variable.
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
Connects to an SMTP email server, storing the established connection in a variable.
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.
smtpConnect --smtphost(String) [--smtpport(Numeric)] [--smtpusername(String)] [--smtppassword(String)] [--smtpusessl(Boolean)] [--enableLog(Boolean)] (EmailConnection)=value
Dependencies
- If you are using the
IntegrationConnection
authentication type, refer to Connections.
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 |
---|---|---|---|---|
SMTP Host | smtphost |
Required |
Text |
SMTP address of the mail server. |
SMTP Port | smtpport |
Optional |
Number |
SMTP server TCP port used for the connection. |
Authentication Type | authenticationtype |
Required |
Text |
The type of authentication. See the authenticationType parameter options. |
SMTP Connection | smtpconnection |
Required when the authenticationtype parameter is IntegrationConnection |
text |
Connections available in your tenant. |
SMTP User name | smtpusername |
Optional |
Text |
Client username registered on the SMTP server. |
SMTP Password | smtppassword |
Optional |
Text |
Client user password registered on the SMTP server. |
Use SSL for SMTP | smtpusessl |
Optional |
Boolean |
Enables the use of the SSL |
Enable log | enableLog |
Optional |
Boolean |
Enables protocol logging, if available. The log file is stored in the %localappdata%\IBM Robotic Process Automation directory. |
authenticationType
parameter options
The following table displays the options available for the authenticatinType
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. |
Example
Sends an email using an SMTP connection variable.
defVar --name emailConnection --type EmailConnection
defVar --name receiveremail--type List --innertype String --value "[email@email.com]"
smtpConnect --smtphost "smtp.gmail.com" --smtpport 465 --smtpusername "useremail@gmail.com" --smtppassword userpassword --smtpusesslemailConnection=value
emailSend --connection ${emailConnection} --to ${receiverEmail} --from "useremail@gmail.com" --bodytype "Text" --body "Message body"
emailDisconnect --connection ${emailConnection}
// Sends an email via SMTP protocol and terminates the connection to the server.
Limitations
- 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. The workaround is to add your email provider to the Microsoft™ Outlook service and use the
Connect to Microsoft Outlook (
outlookConnect
) command.