Move Email

Moves an email message to a specific folder.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Moves an email message to a specific folder, which should already be on the connected email server.

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.

emailMove --folder(String) [--moveconversation(Boolean)] --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
Folder folder Required Text Name of the folder to which the email message should be moved. This name must be exactly the same as the name of the folder created on the email server used.

Note:When using Outlook, Office365, Exchange or Thunderbird as email server, use the complete path to the folder.
Move Conversation moveconversation Optional Boolean When enabled, all the conversation for that message is also moved to another folder along with the email message itself.
Message message Required Email Message Variable of type Email Message that contains the email to be moved.

Example

After connecting to an email server, the Move Email command moves email messages from that connection to the "Trash" folder.

defVar --name movedMessage --type EmailMessage
defVar --name emailConnection --type EmailConnection
// Connect to the Outlook365 IMAP server.
imapConnect --mailhost "outlook.office365.com" --mailport 993 --usessl--username "useremail@email.com" --mailusername "useremail@email.com" --mailpassword userpassword --enableLogemailConnection=value
foreach --collection "${emailConnection}" --variable "${movedMessage}"
	emailMove --folder "Trash" --moveconversation--message ${movedMessage}
endFor
emailDisconnect --connection ${emailConnection}
// Moves email messages to the "Trash" folder on the email server.

Example 2

After connecting to an email server, the Move Email command moves email messages from that connection to the "yourFolderName" folder inside your inbox.

defVar --name movedMessage --type EmailMessage
defVar --name emailConnection --type EmailConnection
// Connect to the Thunderbird IMAP server.
imapConnect --mailhost "imap.thunderbird.com" --mailport 993 --mailusername "useremail@email.com" --mailpassword userpassword useremail@email.com
foreach --collection "${emailConnection}" --variable "${movedMessage}"
	emailMove --folder "INBOX/yourFolderName" --message ${movedMessage}
endFor
emailDisconnect --connection ${emailConnection}
// Moves email messages to the "yourFolderName" folder on the email server.

Notes:

  • Use a valid email connection to run this examples.
  • If you are moving emails between folders inside your inbox, make sure to use the complete path to the folder.