-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh_dashboard.py
137 lines (90 loc) · 4.09 KB
/
refresh_dashboard.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import win32com.client
from PIL import ImageGrab
import time
from directories import *
import datetime as dt
File = win32com.client.Dispatch("Excel.Application")
Workbook = File.Workbooks.Open(dashboard_inflow_canali_prodotti+r"\Dashboard inflow - Raffaele.xlsb")
File.Visible = True
Workbook.RefreshAll()
File.CalculateUntilAsyncQueriesDone()
Workbook.Save()
Worksheet = Workbook.Worksheets("Email")
Copyrange= Worksheet.Range('B6:k102')
Copyrange.CopyPicture(Appearance=1, Format=2)
ImageGrab.grabclipboard().save(pictures+r"\Dashboard inflow.png")
Workbook.Close()
time.sleep(5)
Workbook = File.Workbooks.Open(dashboard_inflow_canali_prodotti+r"\Condivisi\Dashboard inflow.xlsb")
File.Visible = True
Workbook.RefreshAll()
File.CalculateUntilAsyncQueriesDone()
Workbook.Save()
Workbook.Close(SaveChanges=False)
time.sleep(5)
workbook_path = dashboard_inflow_canali_prodotti+r"\Condivisi\Dashboard inflow - Confronto SFDC vs. SAP.xlsb"
Workbook = File.Workbooks.Open(workbook_path)
File.Visible = True
Workbook.RefreshAll()
File.CalculateUntilAsyncQueriesDone()
Workbook.Save()
#Email SF vs. SAP
Sheet = Workbook.Sheets.Item("Sintesi")
Copyrange = Sheet.Range('L7:T14')
Copyrange.CopyPicture(Appearance=1, Format=2)
image_path = ImageGrab.grabclipboard().save(pictures+r"\Dashboard inflow - Confronto SFDC vs. SAP.png")
Workbook.Close(SaveChanges=False)
File.Quit()
html_body = """
<div>
<p>Buongiorno Marco,<br><br>
qui il confronto SF vs. SAP:<br><br>
<div>
<img src={}></img>
</div><br><br>
Un saluto,<br>Raffaele<br><br></p>
</div>
"""
outlook = win32com.client.Dispatch('Outlook.Application')
message = outlook.CreateItem(0)
message.To = "[email protected]"
message.CC = "[email protected];[email protected]"
message.Subject = 'Salesforce vs SAP'
message.HTMLBody = html_body.format(image_path)
message.Display()
###############################################################
#<div><img width="280" height="45" src=https://cdn.wolterskluwer.io/wk/fundamentals/1.15.2/logo/assets/medium.svg></img></div>
html_body = """
<div>
<p>
Buongiorno,<br><br>
in allegato la dashboard aggiornata.<br><br>
Raffaele
</p>
<div><hr size="1" width="100%" align="center"></div>
<div><hr size="1" width="100%" align="center"></div>
<br>
<div><p>Aggiornamento al {}</p></div>
<div>
<span lang="IT">
<a href="https://nam04.safelinks.protection.outlook.com/ap/x-59584e83/?url=https%3A%2F%2Fwolterskluwer-my.sharepoint.com%2F%3Ax%3A%2Fp%2Fraffaele_sportiello%2FEaIMGC62qmZFruYFdZFtpqUBF4RZNhrybnsO_-vTklLzTA%3Fe%3DiPyaXe&data=05%7C01%7CRaffaele.Sportiello%40wolterskluwer.com%7C7656ec3191b7425e5ddf08db1e13f477%7C8ac76c91e7f141ffa89c3553b2da2c17%7C0%7C0%7C638136843317728776%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HzXyl5BWjxnXomNvjcL5qEAszwqkK%2Bo1Wp%2BHnJ3zTQY%3D&reserved=0" originalsrc="https://wolterskluwer-my.sharepoint.com/:x:/p/raffaele_sportiello/EaIMGC62qmZFruYFdZFtpqUBF4RZNhrybnsO_-vTklLzTA?e=iPyaXe" shash="zaNwpHtkDDyF+cayCzaAtsK8lAqNhyt2033mQ5Y9QuS6seLu4pYbnL4SJk2JdGJ8amY+ftr1dBEzuE0R9teOdxfsbcp8U055kRtDzMbfFgQpitxl6qzXv2mHgKvRNPnKmox3RXw4xsIwrJVtvlnAlNGlZ51k4/Pzau8clAs8GFU=">
<span lang="IT">Clicca qui per visualizzare la dashboard completa</span>
</a>
</span>
<p style=" background:#007AC3;font-size:18.0pt;color:white;letter-spacing:.75pt;font-weight:bold;">
<span lang="IT">Inflow</span>
<span lang="IT">mese </span>
</p>
<div>
Dashboard
</div>
<div>
</div>
</div>
"""
outlook = win32com.client.Dispatch('Outlook.Application')
message = outlook.CreateItem(0)
message.To = "[email protected]"
message.Subject = 'Dashboard inflow'
message.HTMLBody = html_body.format((dt.date.today()-dt.timedelta(days=1)).strftime('%d/%m/%Y'))
message.Display()