-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathanku_main.py
55 lines (44 loc) · 1.38 KB
/
anku_main.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
#-*- coding: utf-8 -*-
#!/usr/bin/python
#filename : anku_main.py
#author : doCooler
import os
import anku_sendmail
import ConfigParser
import anku_parserxlsx
class sendSalaryText:
def __init___(self):
self.mail_session = ''
def sendReport(self,to_addr, attachment = []):
#print("debug sendReport")
self.mail_session.set_msg_info(to_addr, attachment)
self.mail_session.send_mail()
print('send mail to ' + to_addr + ' Done')
def sendAll(self):
self.mail_session = anku_sendmail.Ak_sendMail()
xls = anku_parserxlsx.rw_excel()
#检测
ret = xls.check_excel()
if ret == 1:
return 1
print("check excel ok!")
rows = xls.get_rows()
rows += 1
for i in range(1, rows):
to_addr = xls.gen_excel(i)
print ("send mail to " + to_addr)
strattach = 'tmp' + repr(i) + '.xls'
print (strattach)
attachname = [strattach]
#print (attachname)
self.sendReport(to_addr,attachname)
xls.del_excel(i)
#self.mail_session.quit_mail()
return 0
if __name__ == "__main__":
session = sendSalaryText()
ret = session.sendAll()
if ret == 0:
print ("Send Sucess!")
else:
print ("Send Failed!")