Delete Email

Deletes an email message from the email server.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Deletes an email message from the email server, moving it to the trash.

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.

emailDelete --message(EmailMessage)

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
Message message Required Email Message Variable of type Email Message that contains the email to be deleted.

Example

Deletes email messages, from the specified email server, that meet the specifications of the filter defined in Apply Search Filters.

defVar --name emailConnection --type EmailConnection
defVar --name messageToDelete --type EmailMessage
defVar --name from --type List --innertype String --value "[user1@gmail.com]"
defVar --name subject --type List --innertype String --value "[Enter here the subject of the email message that will be deleted]"
imapConnect --mailhost "outlook.office365.com" --mailport 993 --usessl--username "useremail@email.com" --mailusername "useremail@email.com" --mailpassword userpassword --enableLogemailConnection=value
// Apply filters in the "From" and "Subject" fields in the connection with the returned email server, so that when using the connection again, only the email message whose filter was applied will be deleted.
emailApplySearchFilters --from ${from} --subjectdirective "All" --inclusivesubject ${subject} --wordsdirective "All" --connection ${emailConnection}
foreach --collection "${emailConnection}" --variable "${messageToDelete}"
emailDelete --message ${messageToDelete}
endFor
// Delete the message, moving it to the email server's trash.
Note:Use a valid email connection to run this example script.

Limitations

The Delete Email command must be used within the repetition structure For Each.