Hugo-Hattori / RPA_email_report

Robotic Process Automation Project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RPA E-mail Report

This is a small project created for academic purposes. The objective of this project is to build a RPA code that analyzes database originated information and automatically sends an E-mail Report regarding simulated purchase orders.

Packages used:

  • pyautogui
  • time
  • pyperclip
  • pandas

This automation mainly relies on pyautogui package in order to automatically control the mouse and keyboard to perform actions described below.

Getting the data

The data is collected from an online database, in order to download it we need to input our credentials.

#Passo 2: Preencher o login
pyautogui.click(x=968, y=376)
pyautogui.write(username)
#Passo 3: Preencher a senha
pyautogui.click(x=968, y=452)
pyautogui.write(password)
#Passo 4: Apertar em acessar
pyautogui.click(x=968, y=525)
time.sleep(5)
#Passo 5: Selecionar arquivo com dados do relatório
pyautogui.click(x=420, y=459)
#Passo 6: Baixar arquivo
pyautogui.click(x=545, y=200)

Data Analysis

The data acquired in question is presented in "Compras.csv". Now we need to access the .csv file and process the data in order to extract the output necessary for the report.

#Passo 7: Cálculo dos indicadores
tabela = pd.read_csv(r"C:\Users\Hugo\Downloads\Compras.csv", sep=";")
total_gasto = tabela["ValorFinal"].sum()
quantidade = tabela["Quantidade"].sum()
preco_medio = total_gasto/quantidade

Sending the E-mail Report

The last step is to send the e-mail report containing the output previously extracted from the "Compras.csv" file.

#Passo 9: Clicar em "escrever"
pyautogui.click(x=138, y=195)
time.sleep(5)
#Passo 10: escrever o destinatário
pyautogui.write("136493140+Hugo-Hattori@users.noreply.github.com")
pyautogui.press("tab") #confirma o destinatário
pyautogui.press("tab") #passa para o próximo campo
#Passo 11: escrever assunto
pyperclip.copy("Relatório de Compras")
pyautogui.hotkey("ctrl","v")
pyautogui.press("tab")
#Passo 12: escrever corpo do texto
texto = f"""
Prezados,
Segue resumo das compras:
Gasto Total: R${total_gasto:,.2f}
Quantidade: {quantidade:,}
Preço Médio: R${preco_medio:,.2f}
Att.,
Hugo Hatori"""
pyperclip.copy(texto)
pyautogui.hotkey("ctrl","v")
pyautogui.hotkey("ctrl","enter") #envia o e-mail

Note: in this case sending the e-mail only works if you're previously logged in your e-mail account.

Disclaimer: the website used in this project was created as a form of simulating a log in process and the data presented in "Compras.csv" is fictitious and only used for academic purpose.

About

Robotic Process Automation Project.

License:MIT License


Languages

Language:Jupyter Notebook 79.5%Language:Python 20.5%