-
Notifications
You must be signed in to change notification settings - Fork 0
/
0-InvoicesFromEmail.robot
47 lines (35 loc) · 1.46 KB
/
0-InvoicesFromEmail.robot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
*** Settings ***
Documentation This robot accesses a mailbox, reads emails with a subject including the word "Invoice", and then downloads the attachments to the previous folder.
Library RPA.Email.ImapSmtp
Library RPA.FileSystem
Library String
Library RPA.Robocorp.Vault
*** Variables ***
${INVOICES_DIR} ${CURDIR}${/}%{INVOICES_DIR}
${mailbox} %{MAILBOX}
${mailserver} %{MAILSERVER}
${mailport} %{MAILPORT}
*** Tasks ***
Read Invoices from Email
Access Mailbox
Search Emails and Download Invoices
*** Keywords ***
Access Mailbox
${secret} Get Secret Mailbox
${emailpassword}= Set Variable ${secret}[password]
Authorize Imap ${mailbox} ${emailpassword} ${mailserver} ${mailport}
Search Emails and Download Invoices
@{messages}= List Messages criterion=SUBJECT "Invoice" UNSEEN
# Loop Messahes including subject with "Invoice"
FOR ${message} IN @{messages}
Log ${message}[uid] ${message}[Date] ${message}[From]
IF ${message}[Has-Attachments]
Log To Console Saving attachment for: ${message}[Subject]
${attachments}= Save Attachment
... ${message}
... target_folder=${INVOICES_DIR}
... overwrite=True
Log To Console Saved attachments: ${attachments}
END
Mark As Read UID ${message}[uid]
END