Email & API commands
mail Mail
Sends email (SMTP) and works with a mailbox (IMAP): read lists messages as records; their Id is what saveattachments, move, delete and markread take. The account (user name and password) comes from a vault credential: choose --vault and --credential.
Parameters of every variant
| Parameter | Value | Default | Description |
|---|---|---|---|
--retry | number | Number of retry attempts. When not set, screen and file commands try once more after a passing problem (a page still loading, a covered element, a locked file); 0 turns that off | |
--retryinterval | number | 1 | Seconds between retries |
Actions (--action)
--action:send
Sends a message through an SMTP server. A failed send is not repeated by --retry once the server may have taken the message.
| Parameter | Value | Default | Description |
|---|---|---|---|
--smtp required | text | SMTP server, e.g. smtp.gmail.com or smtp.office365.com | |
--port required | number | 587 (STARTTLS, usual), 465 (TLS) or 25 (internal relays) | |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret). Leave empty for a relay that takes mail without signing in | |
--from required | text | Sender address, e.g. bot@company.com or "Robot <bot@company.com>" | |
--to required | text | Recipients, separated by , or ; | |
--cc | text | Copy recipients, separated by , or ; | |
--bcc | text | Blind copy recipients, separated by , or ; | |
--replyto | text | Address that replies go to, when not the sender | |
--subject required | text | ||
--body required | text | ||
--bodytype | one of text, html | text | |
--attachment | text | File paths, separated by , or ; A file on the agent machine. | |
--priority | one of low, normal, high | normal | Importance shown by mail programs |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2, none | password: sign in with the credential; none: send without signing in (relays); oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off. When not set: password when --credential is set, otherwise none | |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) |
--action:read
Messages of a folder, newest first, as a list of records (Id, From, FromName, To, Cc, Subject, Date, Body, HtmlBody, IsRead, Attachments).
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--folder | text | INBOX | Mail folder, e.g. INBOX or Processed (mail --action:folders lists them) |
--unread | true / false | true | Only unread messages |
--from | text | Only messages whose sender contains this | |
--to | text | Only messages whose recipients contain this | |
--subject | text | Only messages whose subject contains this | |
--body | text | Only messages whose text contains this | |
--since | any value | Only messages received on or after this date | |
--before | any value | Only messages received before this date | |
--hasattachments | true / false | true: only messages with attachments; false: only messages without | |
--max | number | 50 | At most this many messages |
--markread | true / false | false | Mark the returned messages as read |
--output required | variable name | Variable that receives the result |
--action:count
Number of messages in a folder that match the same filters as read (default: the unread ones).
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--folder | text | INBOX | Mail folder, e.g. INBOX or Processed (mail --action:folders lists them) |
--unread | true / false | true | Only unread messages |
--from | text | Only messages whose sender contains this | |
--to | text | Only messages whose recipients contain this | |
--subject | text | Only messages whose subject contains this | |
--body | text | Only messages whose text contains this | |
--since | any value | Only messages received on or after this date | |
--before | any value | Only messages received before this date | |
--hasattachments | true / false | true: only messages with attachments; false: only messages without | |
--output required | variable name | Variable that receives the result |
--action:folders
The full names of the mail folders of the account (e.g. INBOX, Archive/2024), as a list.
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--output required | variable name | Variable that receives the result |
--action:saveattachments
Saves the attachments of a message into a folder; --output receives the list of files.
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--folder | text | INBOX | Mail folder, e.g. INBOX or Processed (mail --action:folders lists them) |
--id required | any value | Id of a message from mail read, e.g. $message.Id$ (valid in the folder it was read from) | |
--destination required | text | Folder for the files (existing files are kept; a number is added to the name) A folder on the agent machine. | |
--filter | text | * | File name pattern, e.g. *.pdf |
--output | variable name | Variable that receives the result |
--action:move
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--folder | text | INBOX | Mail folder, e.g. INBOX or Processed (mail --action:folders lists them) |
--id required | any value | Id of a message from mail read, e.g. $message.Id$ (valid in the folder it was read from) | |
--target required | text | Mail folder to move the message to, e.g. Processed |
--action:delete
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--folder | text | INBOX | Mail folder, e.g. INBOX or Processed (mail --action:folders lists them) |
--id required | any value | Id of a message from mail read, e.g. $message.Id$ (valid in the folder it was read from) |
--action:markread
| Parameter | Value | Default | Description |
|---|---|---|---|
--server required | text | IMAP server, e.g. imap.gmail.com or outlook.office365.com | |
--port | number | 993 | 993 for TLS (usual), 143 for STARTTLS or unencrypted |
--vault | text | Vault that holds the mail account (Vaults page); --credential is then the name of the credential in it | |
--credential required | any value | The mail account: the name of a credential in --vault (its user name and password, kept on the Vaults page), or a credential variable ($cred$). Gmail, Outlook.com and Yahoo need an app password; with --authtype:oauth2 the credential is the app registration (client id / client secret) | |
--security | one of auto, ssl, starttls, none | auto | auto: TLS on ports 465/993, STARTTLS when the server offers it on other ports (a password is never sent unencrypted); ssl: TLS from the start; starttls: must switch to TLS; none: unencrypted (internal servers only) |
--ssl | true / false | Older form of --security: false = none, true = TLS or STARTTLS (--security wins when both are set) | |
--timeout | number | 60 | Seconds to wait for the mail server before giving up |
--ignoresslerrors | true / false | false | Accept any server certificate (internal servers with a self-signed certificate); keep false for public servers |
--authtype | one of password, oauth2 | password | oauth2: Microsoft 365 sign-in with an app registration (IMAP.AccessAsApp / SMTP.SendAsApp), for mailboxes where password sign-in is switched off |
--tenant | text | oauth2: the Microsoft 365 directory, e.g. contoso.onmicrosoft.com or its id | |
--mailbox | text | oauth2: the address whose mailbox is used (send: the --from address when empty) | |
--folder | text | INBOX | Mail folder, e.g. INBOX or Processed (mail --action:folders lists them) |
--id required | any value | Id of a message from mail read, e.g. $message.Id$ (valid in the folder it was read from) | |
--read | true / false | true | false marks the message as unread |
Examples
mail --action:send --smtp:"smtp.gmail.com" --port:587 --vault:"Mail" --credential:"Robot mailbox" --from:"bot@company.com" --to:"admin@company.com" --cc:"manager@company.com" --subject:"RPA Report" --body:$reportContent$ --bodytype:html --attachment:"C:\report.pdf"
mail --action:send --smtp:"relay.company.local" --port:25 --authtype:none --from:"bot@company.com" --to:"team@company.com; boss@company.com" --replyto:"help@company.com" --priority:high --subject:"Done" --body:"All invoices are booked"
mail --action:read --server:"imap.gmail.com" --vault:"Mail" --credential:"Robot mailbox" --subject:"Invoice" --since:$yesterday$ --hasattachments:true --max:20 --output:messages
mail --action:count --server:"imap.gmail.com" --vault:"Mail" --credential:"Robot mailbox" --output:unreadCount
mail --action:folders --server:"imap.gmail.com" --vault:"Mail" --credential:"Robot mailbox" --output:folders
mail --action:saveattachments --server:"imap.gmail.com" --credential:$mailCred$ --id:$message.Id$ --destination:"C:\Inbox" --filter:"*.pdf" --output:files
mail --action:move --server:"imap.gmail.com" --credential:$mailCred$ --id:$message.Id$ --target:"Processed"
mail --action:markread --server:"imap.gmail.com" --credential:$mailCred$ --id:$message.Id$
mail --action:delete --server:"imap.gmail.com" --credential:$mailCred$ --id:$message.Id$
restapi REST API
Makes an HTTP request; the response is stored as a record variable.
Parameters of every variant
| Parameter | Value | Default | Description |
|---|---|---|---|
--url required | text | ||
--query | text | Query string as comma-separated name=value pairs, e.g. page=1,search=$term$ (URL-encoded for you) | |
--headers | text | Comma-separated Key=Value pairs | |
--body | any value | ||
--bodytype | one of json, xml, text, formdata, urlencoded | json | |
--file | text | File to upload (formdata) A file on the agent machine. | |
--saveto | text | Download: save the response to this file instead of reading it (the record then has File; an error answer stays in Body) A file on the agent machine. | |
--credential | $variable$ | ||
--authtype | one of basic, bearer, apikey | ||
--apikey | text | X-API-Key | API key header name |
--output | variable name | Variable that receives the result | |
--timeout | number | 30 | Timeout in seconds |
--retry | number | Number of retry attempts. When not set, screen and file commands try once more after a passing problem (a page still loading, a covered element, a locked file); 0 turns that off | |
--retryinterval | number | 1 | Seconds between retries |
--followredirects | true / false | true | |
--ignoresslerrors | true / false | false |
Actions (--action)
--action:get
No further parameters.
--action:post
No further parameters.
--action:put
No further parameters.
--action:delete
No further parameters.
--action:patch
No further parameters.
--action:head
No further parameters.
--action:options
No further parameters.
Examples
restapi --action:get --url:"https://api.example.com/orders" --query:"status=open,page=1" --output:response
json --action:getvalue --source:$response.Json$ --path:"data.orders[0].customer.name" --output:name
json --action:getvalue --source:$response.Json$ --path:"data.total" --default:0 --output:total
json --action:count --source:$response.Json$ --path:"data.orders" --output:orderCount
json --action:todatatable --source:$response.Json$ --path:"data.orders" --output:orders
json --action:parse --text:$response.Body$ --output:doc
json --action:readfile --file:"C:\config.json" --output:config
json --action:setvalue --name:request --path:"customer.id" --value:42
json --action:setvalue --name:request --path:"items[0].sku" --value:"A-1"
json --action:remove --name:request --path:"draft"
json --action:stringify --source:$request$ --output:body
json --action:writefile --source:$request$ --file:"C:\out\request.json"
json --action:keys --source:$config$ --output:names
restapi --action:get --url:"https://api.example.com/users" --headers:"Content-Type=application/json,Authorization=Bearer $token$" --output:response
restapi --action:post --url:"https://api.example.com/users" --headers:"Content-Type=application/json" --body:$jsonBody$ --output:response
restapi --action:put --url:"https://api.example.com/users/1" --headers:"Content-Type=application/json" --body:$updateData$ --output:response
restapi --action:delete --url:"https://api.example.com/users/1" --headers:"Authorization=Bearer $token$" --output:response
restapi --action:patch --url:"https://api.example.com/users/1" --headers:"Content-Type=application/json" --body:$patchData$ --output:response
restapi --action:post --url:"https://api.example.com/upload" --bodytype:formdata --file:"C:\report.pdf" --output:response
restapi --action:post --url:"https://secure-api.com/data" --credential:$apiCred$ --authtype:basic --body:$payload$ --output:response