-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh_dashboard_indiretta.py
44 lines (34 loc) · 1.44 KB
/
refresh_dashboard_indiretta.py
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
import win32com.client as client
from directories import dashboard_inflow_canali_prodotti
import time
############################################################################################################
dashboard_inflow_indiretta = dashboard_inflow_canali_prodotti + r"\Condivisi\Dashboard inflow - Indiretta.xlsb"
File = client.Dispatch("Excel.Application")
Workbook = File.Workbooks.Open(dashboard_inflow_indiretta)
File.Visible = True
Workbook.RefreshAll()
File.CalculateUntilAsyncQueriesDone()
Workbook.Save()
File.Quit()
import psutil
def kill_excel():
for proc in psutil.process_iter():
if proc.name() == "EXCEL.EXE":
proc.kill()
#############################################################################################################
time.sleep(10)
html_body = """
<div>
<p>Ciao Francesco,<br><br>
in allegato il file aggiornato.<br><br>
Un saluto,<br>Raffaele<br><br></p>
</div>
"""
outlook = client.Dispatch('Outlook.Application')
message = outlook.CreateItem(0)
message.To = "[email protected]"
message.Subject = 'Inflow indiretta'
message.HTMLBody = html_body
message.Attachments.Add(Source=dashboard_inflow_indiretta)
message.Display()