Man illustrationFlower illustration

A Sample RPA Process with E-mail Operations

Estimated reading: 8 minutes 466 views

How to design a sample process that includes e-mail operations with Robusta RPA tool step by step?

PROCESS SCENARIO

In this tutorial:

Connect to an e-mail account and search for unread e-mails with a specific subject and an attached file.

Forward each matching e-mail that meets certain conditions to another e-mail account. 

For the e-mails which do not meet the condition, reply to the sender that the request is invalid.

STEP BY STEP PROCESS

1.Drag and drop Imap/Smtp connection activity under Mail component to connect to e-mail account.

INFO – While SMTP protocol is used for sending e-mail; IMAP protocol is used for e-mail reading.

Mail > Imap/Smtp connection

NameImap/Smtp connection : Connect to E-mail account
Configuration nameconnectionName
*Connection nametestCon
*Imap hostimap.gmail.com
*Imap port993
*Imap userE-mail address for IMTP protocol.
*Imap password${password}
Imap sslTrue
*Smtp hostsmtp.gmail.com
*Smtp port587
*Smtp userE-mail address for SMTP protocol.
*Smtp password${password}
Smtp tls enabledTrue
Smtp tls requiredTrue

2. Provide the configuration of both protocols to be able to perform e-mail operations.

3. To connect to the Gmail account, get information from the relevant page of Google. (https://support.google.com/mail/answer/7126229?hl#zippy=%2Cstep-change-smtp-other-settings-in-your-email-client)

INFO – Data Object allows to define a variable and use it in any activity in the process. Click any area in the process design area to open the Data Object field.

4. In the Data Object field, define a variable named “password” and use it in the password fields.

INFO – Write the variable name between curly braces after a dollar sign (${}).

5. Find the date three days before today with the Script task activity.

INFO – It will be using it as the minimum date in the Mail search activity

6. Drag and drop Script task activity under Activities component and use the javascript to find the date.

7. Assign the current date to the variable threeDaysAgo with the New Date function.

INFO – The current date that is assigned is the form of year, month, day with hyphens between them.

8. Update this variable that was created to be the date of 3 days ago. 

9. Convert this variable to string format with toLocaleDateString function.

10. Concatenate them by adding a dot between them. Save this variable with the execution.setVariable function to use it as a minimum date.

INFO – The MinDate variable here will be used to find e-mails less than 3 days old.

12. Write the variable name between curly braces after a dollar sign.

Activities> Script task

Script formatjavascript
Scriptvar threeDaysAgo = new Date();
threeDaysAgo.setDate(threeDaysAgo.getDate()-3);
var date = threeDaysAgo.toLocaleDateString();
var splitDate = date.split(“-“);
var year = splitDate[0];
var month = splitDate[1];
var day = splitDate[2];
var minDate = day+”.”+month+”.”+year;
execution.setVariable(“minDate”, minDate);
NameScript task : Find three days ago
ExclusiveTrue

13. Use the Search activity under the Mail component.

14. In the connection name field, select the connection reference name that is defined in the first activity from the list.

15. Find the e-mails with the subject containing the phrase “Flight Routes” and containing an attached file. For this, write “Flight Routes” in the Subject field and tick the has attachment box.

16. Do not change the default value of INBOX in the Folder name field, and provide the relevant search to be in the Inbox.

17. By selecting the Unread box, search for unread e-mails, and define a variable in the Dataset field to assign all e-mails’ data to a dataset.

18. Set the e-mail limit to be searched as 10 in the Search limit field. This means that even if there are more than 10 e-mails matching the search criteria, only the 10 most recent e-mails will be imported into the dataset.

19. Leave the From parameter blank, where we can choose from whom the e-mail came from.

Mail > Search

NameSearch : E-mails for flight routes price request
*Connection name${testCon}
*Folder nameINBOX
Has attachment?True
Search limit10
Min date${minDate}
SubjectFlight Routes
UnreadTrue
*New dataset nameemailSearchDS

INFO – If you want to see Dataset, open an Excel file that contains the data of the dataset resulting from this activity. This picture contains information we received via e-mail (Such as subject, sender’s e-mail, mail body etc.).

20.Find the number of e-mails transferred to the dataset using the Get size activity under the Dataset component.

21. Choose the ROW option in the Size type field from the list.

Dataset > Get size

NameGet size : Request count
*Dataset name${emailSearchDS}
Size typeROW
*Result variable nameemailSearchDSSize

22. Terminate this process if no e-mails are found, and continue if there is at least one e-mail.

23. To do this, use a gateway that allows us to control how a process flows according to the conditions we set.

24. For each arrow leaving the gateway, set a condition expression according to the e-mail count variable.

25. If the value of this variable is 0, end the process flow. Otherwise, choose the default flow option, and do not set any condition expression.

26. The process will continue from here if it does not match a condition.

Flow condition(${emailSearchDSSize==0})

27. If the process does not end at this point, continue with a loop activity, since the operations will be done independently for each e-mail.

28. Include the Sub-process activity from the Structure section to create a loop activity in the process.

29. As in the main process, you need to create a flow with a beginning and end event in this sub-process and need to define how many times this sub-process will be repeated in the Cardinality field.

30. If you do not make this definition, the sub-process will run once.

31. In this example, since you want to loop as many as the number of matching e-mails, write the variable that holds the number of e-mails in the Cardinality field in curly brackets.

32. Choose the value of the Multi-instance type field as Sequential because you want each operation to be done sequentially in our loop.

33. The “loopCounter” variable is automatically defined at the beginning of the loop.

INFO – loopCounter, which first takes a value of 0 increases by 1 at each iteration. When the value of the “loopCounter” variable reaches the Cardinality value, the loop is automatically terminated.

Structural> Sub process

NameLoop for each e-mail request
ExclusiveTrue
Multi-instance typeSequential
Cardinality (Multi-instance)${emailSearchDSSize}

34. In Read/Save/Attachment activity, after selecting the testCon connection name from the list in the Connection name field, write the loopCounter variable in the E-mail number field, which indicates the current iteration number. In this way, ensuring that e-mails are processed one by one.

35. Since you want to archive the attached files, check the Save attachments box and enter the directory path where you want the files to be saved in the Save Path field.

36. By selecting the Mark as Read option, ensure that the e-mails are marked as read.

37. Thus, when the process runs again, it will not be processing the same e-mails again and again. Import the list of attached files into a dataset.

Mail > Read/Save/Attachment

NameRead/Save/Attachment : Dowload to ‘archieve’ folder
*Connection name${testCon}
*Dataset nameemailSearchDS
Mail no${loopCounter}
Mark as read?True
Save attachments?True
Save pathThe location you want to save the files.
Attachment database nameAttachmentDS

38. In this step, similar to the use of the Get size activity that we explained in the first parts of the process, find the row number of the dataset to which the list of the attached files is transferred.

Dataset > Get size

NameGet size : Attached file count
*Dataset name${AttachmentDS}
Size typeROW
*Result variable namelistFileDSSize

39. After finding the number of attached files, add another gateway to the process as we want to perform a different operation if there is more than 1 attached file, and a different operation if there is only 1 file.

40. If there is more than one attached file, continue with the Reply activity, and send the message that includes “Cannot process more than one attached file”.

Flow condition(${listFileDSSize>=2})

41. Continue with the Reply activity and select the testCon connection from the list in the connection name field

42. Write the loopCounter variable in the mail no field to respond to each e-mail.

43. Later, choose the is HTML? box because e-mail body is in html format.

44. At the same time, select the Reply all option for reply all.

Mail > Reply

NameReply : Request is not valid
*Connection name${testCon}
*Dataset name${emailSearchDS}
Mail no${loopCounter}
MessageCannot process more than one attached file
Is HTML?True
Reply all?True

45. If there is 1 file attached, forward the e-mail to another e-mail address with the Forward activity. Write the relevant information from and to e-mail addresses, e-mail no, subject, and message fields.

Default flowTrue

Mail > Forward

MailForward
*Connection name${testCon}
*Dataset name${emailSearchDS}
Mail no${loopCounter}
*Fromsender’s e-mail address
*Torecipient’s e-mail address
MessageThis mail is forwarded by Robusta RPA tool.

46. Complete the subprocess flow with an End event.

47. Use another end event to terminate the main process.

Share this Doc

A Sample RPA Process with E-mail Operations

Or copy link

CONTENTS
Chat Icon Close Icon