SAP Help Home SAP Intelligent RPA Help Portal SAP Intelligent RPA Community

Module - Email

The activities are based on the MS Outlook application.

Activities

Fetch Emails New

Send an asynchronous fetch request to refresh emails. Required to refresh a POP3 account (not necessary for IMAP account).


Technical Name Type Minimal Agent Version
fetchMails asynchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
waitDelay New number optional 5000 Time in milliseconds to wait while the asynchronous request ends.

Sample Code:

await irpa_outlook.email.fetchMails();



Search for a specific email.


Technical Name Type Minimal Agent Version
search synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
searchCriteria irpa_outlook.emailSearchCriteria mandatory List of search criteria. Please note that the search criteria are not case sensitive.
sortResultBy irpa_outlook.enums.sortResultBy optional Sort Result By
sortOrder irpa_outlook.enums.sortOrder optional Sort Order

Sample Code:

irpa_outlook.email.search({ searchCriterionList : [ { element: "dateReceived", operand: "equals", value: "2020_12_07" }, { element: "hasAttachment", operand: "equals", value: "1" } ], folder: undefined, folderType: "olFolderInbox", storeName: undefined });

Note:

If you search using the 'dateReceived' criterion, please use the following format "YYYY-MM-DD" or "YYYY_MM_DD"

Note:

If you search using the 'isRead' or 'hasAttachment' criteria, please use one of those values : 0, 1, false, true, no, yes, unread, read

Note:

The separator between subfolders in the folder field can be '\' or '/'

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid search argument
NotFound irpa_core Folder not found


Send Email (Outlook)

Send an email.


Technical Name Type Minimal Agent Version
send synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
emailItemParameters irpa_outlook.emailItemParameters mandatory The email parameters.

Sample Code:

await irpa_outlook.email.send({ To: "foo1@sap.com", CC: "foo2@sap.com", BCC: "foo3@sap.com", Subject: "Hello World !", Body: "Don't forget to say ""Hello""" });

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid email arguments
NotFound irpa_core Attachment not found


Create and Display Email (Outlook)

Create and Display an email.


Technical Name Type Minimal Agent Version
createAndDisplay synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
emailItemParameters irpa_outlook.emailItemParameters mandatory The email parameters.

Sample Code:

await irpa_outlook.email.createAndDisplay({ To: "firstName1.lastName1@myCompany.com", CC: "firstName2.lastName2@myCompany.com", BCC: "firstName3.lastName3@myCompany.com", Subject: "Here is the subject of my email.", Body: "Here is the body of my email." });

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid email arguments
NotFound irpa_core Attachment not found


Send Reply (Outlook)

Send a reply to the current email.


Technical Name Type Minimal Agent Version
sendReply synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
emailReplyItemParameters irpa_outlook.emailReplyItemParameters mandatory Email reply item parameters.

Sample Code:

await irpa_outlook.email.sendReply({ Body: "Thank you for your email<br/>This is an automatic answer" });

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid email arguments
NotFound irpa_core Attachment not found


Send Reply All (Outlook)

Send a 'reply all' to the current email.


Technical Name Type Minimal Agent Version
sendReplyAll synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
emailReplyItemParameters irpa_outlook.emailReplyItemParameters mandatory Email reply item parameters.

Sample Code:

await irpa_outlook.email.sendReplyAll({ Body: "Thank you for your email<br/>This is an automatic answer" });

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid email arguments
NotFound irpa_core Attachment not found


Create Reply and Display (Outlook)

Create a reply to the current email and display it.


Technical Name Type Minimal Agent Version
createReplyAndDisplay synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
emailReplyItemParameters irpa_outlook.emailReplyItemParameters mandatory Email reply item parameters.

Sample Code:

await irpa_outlook.email.createReplyAndDisplay({ Body: "Thank you for your email<br/>This is an automatic answer" });

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid email arguments
NotFound irpa_core Attachment not found


Create Reply All and Display (Outlook)

Create a 'reply all' to the current email and display it.


Technical Name Type Minimal Agent Version
createReplyAllAndDisplay synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
emailReplyItemParameters irpa_outlook.emailReplyItemParameters mandatory Email reply item parameters.

Sample Code:

await irpa_outlook.email.createReplyAllAndDisplay({ Body: "Thank you for your email<br/>This is an automatic answer" });

Errors:

Error Class Package Description
InvalidArgument irpa_core Invalid email arguments
NotFound irpa_core Attachment not found


Save Mail Attachment (Outlook)

Save a mail attachment.


Technical Name Type Minimal Agent Version
emailItem.saveAttachment synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
destinationPath string mandatory Path of the folder where the attachments are to be saved.
attachmentFileName string mandatory Name of the attachment to save.

Sample Code:

await irpa_outlook.email.emailItem.saveAttachment("C:\\temp\\Attachments", "MyAttachment.jpg");

Sample Code:

await irpa_outlook.email.emailItem.saveAttachment("%temp%\\Attachments", "MyAttachment.jpg");

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context
InvalidArgument irpa_core Invalid argument
NotFound irpa_core Destination folder not found


Save All Mail Attachments (Outlook)

Save all the mail attachments.


Technical Name Type Minimal Agent Version
emailItem.saveAllAttachments synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
destinationPath string mandatory Path of the folder where the attachments are to be saved.
extensionsToSkip string optional Extensions to exclude from the attachment save. Multiple extensions must be semi-colon separated, e.g. 'pdf;xlsx;png'.
extensionsToKeep string optional Extensions to include in the attachment save. Multiple extensions must be semi-colon separated, e.g. 'pdf;xlsx;png'.

Output Parameters:

Name Type Description
attachmentsSavedList Array. List of the filenames of the saved attachments.

Sample Code:

let attachmentsSavedList = await irpa_outlook.email.emailItem.saveAllAttachments("C:\\temp\\Attachments", undefined, "pdf;jpg;png;doc");

Sample Code:

let attachmentsSavedList = await irpa_outlook.email.emailItem.saveAllAttachments("%temp%\\Attachments", undefined, "pdf;jpg;png;doc");

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context
InvalidArgument irpa_core No folder defined to save attachments
NotFound irpa_core Destination folder not found


Get Mail Attachments Name (Outlook)

Retrieve the names of attachments.


Technical Name Type Minimal Agent Version
emailItem.getAttachmentsName synchronous WIN-2.0.0

Output Parameters:

Name Type Description
attachmentsNameList Array. List of the attachments' names.

Sample Code:

let attachmentsNameList = await irpa_outlook.email.emailItem.getAttachmentsName();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Delete Email (Outlook)

Delete current email.


Technical Name Type Minimal Agent Version
emailItem.delete synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.delete();

Note:

Deleting an email resets the current email in the context. A good practice is to use Get First Email or Get Last Email activity to select a valid email after deletion.

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Move Email (Outlook)

Move current email to a folder.


Technical Name Type Minimal Agent Version
emailItem.move synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
folder string optional Name or path of the folder.
folderType irpa_outlook.enums.olDefaultFolders optional olFolderInbox Type of the folder.
storeName string optional Name of the store.

Sample Code:

await irpa_outlook.email.move(undefined, "olFolderJunk", undefined);

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context
InvalidArgument irpa_core At least one input parameter is mandatory
NotFound irpa_core The destination folder could not be found


Save As (Outlook)

Save current email in .msg format.


Technical Name Type Minimal Agent Version
emailItem.saveAs synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
filePath string mandatory Full path of the destination file.

Sample Code:

await irpa_outlook.email.saveAs("C:\\temp\\email.msg");

Sample Code:

await irpa_outlook.email.saveAs("%temp%\\email.msg");

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context
InvalidArgument irpa_core Invalid filename
NotFound irpa_core Destination path not found


Get Mail Subject (Outlook)

Retrieve the subject of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getSubject synchronous WIN-2.0.0

Output Parameters:

Name Type Description
subject string Subject of the email.

Sample Code:

let subject = await irpa_outlook.email.emailItem.properties.getSubject();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail ID (Outlook)

Retrieve the ID of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getId synchronous WIN-2.0.0

Output Parameters:

Name Type Description
id string The email ID.

Sample Code:

let id = await irpa_outlook.email.emailItem.properties.getId();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Set Mail Subject (Outlook)

Set the subject of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.setSubject synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
value string mandatory Value to set as subject of the email.

Sample Code:

await irpa_outlook.email.setSubject("Hello World !");

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Set Unread (Outlook)

Set an email as unread.


Technical Name Type Minimal Agent Version
emailItem.properties.setUnread synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.setUnread();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Set Read (Outlook)

Set an email as read.


Technical Name Type Minimal Agent Version
emailItem.properties.setRead synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.setRead();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail Body (Outlook)

Retrieve the body of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getBody synchronous WIN-2.0.0

Output Parameters:

Name Type Description
body string Body of the email.

Sample Code:

let body = await irpa_outlook.email.emailItem.properties.getBody();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get HTML Mail Body (Outlook)

Retrieve the HTML body of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getHTMLBody synchronous WIN-2.0.0

Output Parameters:

Name Type Description
body string HTML body of the email.

Sample Code:

let htmlBody = await irpa_outlook.email.getHTMLBody();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Set Mail Body (Outlook)

Set the body of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.setBody synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
value string mandatory Value to set as body of the email.
isHtmlBody boolean optional false Define if the body is an HTML value.

Sample Code:

await irpa_outlook.email.emailItem.properties.setBody("Don't forget to say \"Hello\"");

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail Recipients (Outlook)

Retrieve the recipients of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getRecipient synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
recipientInfoType irpa_outlook.enums.recipientInfoType optional getRawAddresses What the activity should return.

Output Parameters:

Name Type Description
recipient string Recipients of the email.

Sample Code:

let recipient = await irpa_outlook.email.properties.getRecipient();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail CC (Outlook)

Retrieve the CC of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getCC synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
CCInfoType irpa_outlook.enums.CCInfoType optional getRawAddresses What the activity should return.

Output Parameters:

Name Type Description
cc string CC of the email.

Sample Code:

let cc = await irpa_outlook.email.properties.getCC();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail Sender (Outlook)

Retrieve the sender of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getSender synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
senderInfoType irpa_outlook.enums.senderInfoType optional getRawAddress What the activity should return.

Output Parameters:

Name Type Description
sender string Sender of the email.

Sample Code:

let sender = await irpa_outlook.email.properties.getSender();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail Sent Date (Outlook)

Retrieve the sent date of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getSentDate synchronous WIN-2.0.0

Output Parameters:

Name Type Description
sentDate string Sent date of the email.

Sample Code:

let sentDate = await irpa_outlook.email.properties.getSentDate();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Mail Received Date (Outlook)

Retrieve the received date of an email.


Technical Name Type Minimal Agent Version
emailItem.properties.getReceivedDate synchronous WIN-2.0.0

Output Parameters:

Name Type Description
receivedDate string Received date of the email.

Sample Code:

let receivedDate = await irpa_outlook.email.properties.getReceivedDate();

Errors:

Error Class Package Description
ContextError irpa_outlook No mail found in context


Get Context Overview (Outlook)

Retrieve the context overview. /!\ Please only use this activity during the design of your automation as a helper for test purposes. This activity must be removed in production mode.


Technical Name Type Minimal Agent Version
context.DesignOnly.getContextOverview synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
limit number optional 20 Maximum number of email overviews to return. The default value is 20. For performance reasons, the number of returned email overviews may be lower than the requested number. The count however is always correct.

Output Parameters:

Name Type Description
contextOverview irpa_outlook.contextOverview Context overview.

Sample Code:

await irpa_outlook.email.context.getContextOverview();



Check Current Email

Check if the current email is defined. Useful when using the 'Get Next Email' or 'Get Previous Email' activities to verify if the mail cursor is still inside the context.


Technical Name Type Minimal Agent Version
context.isContextCurrentEmailExist synchronous WIN-2.0.0

Output Parameters:

Name Type Description
isContextCurrentEmailExist boolean True if there is a context in the current email, false otherwise.

Sample Code:

let bCurMailExists = await irpa_outlook.email.context.isContextCurrentEmailExist();



Is there no Context Current Email (deprecated) Deprecated

Check if the current email is undefined. As this activity is deprecated, use 'Check Current Email' activity instead, to check if the current email is defined or not.


Status From Substitute Activity
Deprecated 1.14 irpa_outlook.email.context.isContextCurrentEmailExist


Technical Name Type Minimal Agent Version
context.isContextCurrentEmailNotExist synchronous WIN-2.0.0

Output Parameters:

Name Type Description
isContextCurrentEmailNotExist boolean True if there is no context in the current email, false otherwise.

Sample Code:

let bCurMailDoesNotExists = await irpa_outlook.email.context.isContextCurrentEmailNotExist();



Get Emails Number (Context)

Retrieve the number of email items in the context.


Technical Name Type Minimal Agent Version
context.count synchronous WIN-2.0.0

Output Parameters:

Name Type Description
count number Number of emails in the context.

Sample Code:

let count = await irpa_outlook.email.context.count();



Get First Email (Context)

Within a context, make the first email item as the current email item.


Technical Name Type Minimal Agent Version
context.getFirst synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.context.getFirst();



Get Last Email (Context)

Within a context, make the last email item as the current email item.


Technical Name Type Minimal Agent Version
context.getLast synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.context.getLast();



Get Next Email (Context)

Within a context, make the next email item as the current email item.


Technical Name Type Minimal Agent Version
context.getNext synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.context.getNext();



Get Previous Email (Context)

Within a context, make the previous email item as the current email item.


Technical Name Type Minimal Agent Version
context.getPrevious synchronous WIN-2.0.0

Sample Code:

await irpa_outlook.email.context.getPrevious();