Skip to content

Commit d52d10c

Browse files
committed
Code modification and documentation update
1 parent f33464c commit d52d10c

File tree

5 files changed

+117
-93
lines changed

5 files changed

+117
-93
lines changed

README.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# Template: Standard Robot Framework
1+
# Emails creation from excel file
22

3-
This is the simplest template to start from.
3+
This robot reads excel file as input and then emails data to recipients. Excel example and email template are in devdata folder
44

5-
- Get started from a simple task template in `tasks.robot`.
6-
- Uses [Robot Framework](https://robocorp.com/docs/languages-and-frameworks/robot-framework/basics) syntax.
7-
- You can configure your robot `robot.yaml`.
8-
- You can configure dependencies in `conda.yaml`.
9-
10-
## Learning materials
5+
## Learning materials and example robots
116

127
- [Robocorp Developer Training Courses](https://robocorp.com/docs/courses)
138
- [Documentation links on Robot Framework](https://robocorp.com/docs/languages-and-frameworks/robot-framework)

conda.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ dependencies:
1212
- pip=22.1.2 # https://pip.pypa.io/en/stable/news/
1313
- pip:
1414
# Define pip packages here -> https://pypi.org/
15-
- rpaframework==19.3.1 # https://rpaframework.org/releasenotes.html
15+
- rpaframework==20.1.0 # https://rpaframework.org/releasenotes.html

devdata/Employee data.xlsx

-32 Bytes
Binary file not shown.

devdata/message.template

+66-69
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,69 @@
11
<!doctype html>
22
<html>
3-
4-
<head>
5-
<meta name="viewport">
6-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7-
<title>Email template</title>
8-
<style>
9-
</style>
10-
</head>
11-
12-
<body
13-
style="background-color: #a1a1f6f2; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
14-
<span class="preheader"
15-
style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">Email
16-
generated by Robocorp robot</span>
17-
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body"
18-
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #a1a1f6f2; width: 100%;"
19-
width="100%" bgcolor="#a1a1f6f2">
20-
<tr>
21-
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">&nbsp;</td>
22-
<td class="container"
23-
style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; max-width: 580px; padding: 10px; width: 580px; margin: 0 auto;"
24-
width="580" valign="top">
25-
<div class="content"
26-
style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;">
27-
28-
<!-- Create div box for genertated text -->
29-
<table role="presentation" class="main"
30-
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #ffffff; border-radius: 3px; width: 100%;"
31-
width="100%">
32-
33-
<!-- Set mail main content -->
34-
<tr>
35-
<td class="wrapper"
36-
style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;"
37-
valign="top">
38-
<table role="presentation" border="0" cellpadding="0" cellspacing="0"
39-
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;"
40-
width="100%">
41-
<tr>
42-
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
43-
<p
44-
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
45-
Hello there,</p>
46-
<p
47-
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
48-
Sometimes you just want to send a simple HTML email with a simple design and clear call to
49-
action. This is it. And that is that</p>
50-
<p
51-
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
52-
This is a really simple email template. Its sole purpose is to get the recipient to click the
53-
button with no distractions.</p>
54-
<p
55-
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
56-
Good luck! Hope it works.</p>
57-
</td>
58-
</tr>
59-
</table>
60-
</td>
61-
</tr>
62-
<!-- End mail main content -->
63-
</table>
64-
<!-- End centered div box -->
65-
</div>
66-
</td>
67-
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">&nbsp;</td>
68-
</tr>
69-
</table>
70-
</body>
71-
3+
<head>
4+
<meta name="viewport">
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title>Robot email template</title>
7+
<style>
8+
</style>
9+
</head>
10+
<body
11+
style="background-color: #010037; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
12+
<span class="preheader"
13+
style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">Email
14+
generated by Robocorp robot</span>
15+
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body"
16+
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #010037; width: 100%;"
17+
width="100%" bgcolor="#010037">
18+
<tr>
19+
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">&nbsp;</td>
20+
<td class="container"
21+
style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; max-width: 580px; padding: 10px; width: 580px; margin: 0 auto;"
22+
width="580" valign="top">
23+
<div class="content"
24+
style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;">
25+
<!-- Div for text box -->
26+
<table role="presentation" class="main"
27+
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #ffffff; border-radius: 3px; width: 100%;"
28+
width="100%">
29+
<!-- Set mail main text content -->
30+
<tr>
31+
<td class="wrapper"
32+
style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;"
33+
valign="top">
34+
<table role="presentation" border="0" cellpadding="0" cellspacing="0"
35+
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;"
36+
width="100%">
37+
<tr>
38+
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
39+
<p
40+
style="font-family: sans-serif; font-size: 18px; font-weight: bold; margin: 0; margin-bottom: 15px;">
41+
Hello ${first_name} ${last_name},
42+
</p>
43+
<p
44+
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
45+
We are happy to announce that you have been added to automated email spam flow.
46+
</p>
47+
<p
48+
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
49+
This mail has no specific meaning its just an template. Intent is to show how to use html body with variables from Excel.
50+
</p>
51+
<p
52+
style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
53+
Enjoy!
54+
</p>
55+
</td>
56+
</tr>
57+
</table>
58+
</td>
59+
</tr>
60+
<!-- End mail main text content -->
61+
</table>
62+
<!-- End div text box -->
63+
</div>
64+
</td>
65+
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">&nbsp;</td>
66+
</tr>
67+
</table>
68+
</body>
7269
</html>

tasks.robot

+47-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,63 @@
1-
*** Comments ***
2-
TODO
3-
[ ] Create Excel
4-
[ ] Build Email Template
5-
6-
71
*** Settings ***
82
Documentation Robot for sending emails based on input Excel
9-
... Each Excel sheet will be read in and used
3+
... Each Excel sheet will be read in and used
104
... as input for email
115
126
Library RPA.Excel.Files
7+
Library Collections
8+
Library RPA.Email.ImapSmtp smtp_server=smtp.gmail.com smtp_port=587
9+
Library RPA.Robocorp.Vault
10+
Library OperatingSystem
1311

1412

1513
*** Variables ***
1614
${EXCEL_FILE} ${CURDIR}${/}devdata${/}Employee data.xlsx
15+
${VAULT_NAME} RoboMail
16+
${TEMPLATE_FILE} ${CURDIR}${/}devdata${/}message.template
17+
${SUBJECT} Email notificastion from Robot Robotson
18+
${RECIPIENT} [email protected]
1719

1820

1921
*** Tasks ***
20-
Minimal task
21-
Log To Console \n
22+
Email Excel Data
23+
&{employees_from_excel}= Read Excel Data To Dictionary
24+
Send All Mails &{employees_from_excel}
25+
26+
27+
*** Keywords ***
28+
Read Excel Data To Dictionary
2229
Open Workbook ${EXCEL_FILE}
2330
&{employees_from_excel}= Create Dictionary
2431
@{sheets}= List Worksheets
25-
Log To Console ${sheets}
26-
${worksheet}= Read Worksheet
27-
${first_name}= Get Cell Value 2 B Sheet2
28-
Log To Console ${first_name}
29-
${last_name}= Get Cell Value 3 B
30-
Log To Console ${last_name}
32+
FOR ${sheet} IN @{sheets}
33+
&{current_employee}= Create Dictionary
34+
${current_worksheet}= Read Worksheet ${sheet}
35+
${first_name}= Get Cell Value 2 B
36+
${last_name}= Get Cell Value 3 B
37+
Set To Dictionary ${current_employee}
38+
... First name=${first_name}
39+
... Last name=${last_name}
40+
Set To Dictionary ${employees_from_excel}
41+
... ${sheet}=&{current_employee}
42+
END
3143
Close Workbook
44+
RETURN &{employees_from_excel}
45+
46+
Send All Mails
47+
[Documentation] Generates email body based on input dictionary
48+
... Sends email to recipients
49+
[Arguments] &{data_dict}
50+
${secret}= Get Secret ${VAULT_NAME}
51+
Authorize account=${secret}[username] password=${secret}[password]
52+
${mail_template}= Get File ${TEMPLATE_FILE}
53+
FOR ${employee_sheet} IN @{data_dict}
54+
${first_name}= Set Variable ${data_dict['${employee_sheet}']}[First name]
55+
${last_name}= Set Variable ${data_dict['${employee_sheet}']}[Last name]
56+
${message}= Replace Variables ${mail_template}
57+
Send Message
58+
... sender=${secret}[username]
59+
... recipients=${RECIPIENT}
60+
... subject=${SUBJECT}
61+
... body=${message}
62+
... html=True
63+
END

0 commit comments

Comments
 (0)