|
@@ -47,9 +47,15 @@ def send_email(emails, content, has_overdue):
|
|
|
else:
|
|
|
msg.set_content(name + "您好,\n\n您目前沒有過期的作業。\n更新執行表單請至 https://cmm.ai/pm ,謝謝您。\n\n")
|
|
|
|
|
|
- print ('Sending email to' + msg['To'])
|
|
|
- #server.send_message(msg)
|
|
|
- print ('Email sent to' + msg['To'])
|
|
|
+ print ('Sending email to ' + msg['To'])
|
|
|
+ server.send_message(msg)
|
|
|
+ print ('Email sent to ' + msg['To'])
|
|
|
+ fname = name+'.txt'
|
|
|
+ with open(fname, 'w', encoding="UTF+8") as f:
|
|
|
+ if has_overdue[name] == 1:
|
|
|
+ f.write(content[name])
|
|
|
+ else:
|
|
|
+ f.write(name + "您好,\n\n您目前沒有過期的作業。\n更新執行表單請至 https://cmm.ai/pm ,謝謝您。\n\n")
|
|
|
|
|
|
server.close()
|
|
|
|
|
@@ -59,12 +65,12 @@ sheet_instance = sheet.get_worksheet(0)
|
|
|
records_data = sheet_instance.get_all_records()
|
|
|
#print(records_data[0])
|
|
|
|
|
|
-emails = {"Jared": "jared@choozmo.com", "Morrison": "morrison@choozmo.com", "Ginia": "ginia@choozmo.com", "Doris": "doris@choozmo.com"}
|
|
|
+emails = {"Jared": "jared@choozmo.com", "Morrison": "morrison@choozmo.com", "Ginia": "ginia@choozmo.com", "Doris": "doris@choozmo.com", "Nina": "nina.huang@choozmo.com", "Yukyo": "yukyo@choozmo.com", "Andy": "andy@choozmo.com", "Oak": "oak@choozmo.com", "Zooey": "zooey@choozmo.com", "Syuanyuri": "syuanyuri@choozmo.com", "Wizer": "wizer@choozmo.com", "Jason": "jason@choozmo.com", "Tomoya": "tomoya@choozmo.com", "詠心": "noodlesloves@gmail.com", "献竤": "fxp87257@gmail.com"}
|
|
|
overdue_email_content = {}
|
|
|
has_overdue = {}
|
|
|
|
|
|
for e in emails.keys():
|
|
|
- overdue_email_content[e] = e + "您好,\n\n提醒已過期的作業如下,請務必提醒相關同仁完成作業。\n更新執行表單請至 https://cmm.ai/pm ,謝謝您。\n\n過期作業如下:\n\n"
|
|
|
+ overdue_email_content[e] = e + "您好,\n\n提醒您有已過期的作業,請儘快完成以下作業。\n更新執行表單請至 https://cmm.ai/pm ,謝謝您。\n\n過期作業如下:\n\n"
|
|
|
has_overdue[e] = 0
|
|
|
|
|
|
for data in records_data:
|
|
@@ -80,7 +86,7 @@ for data in records_data:
|
|
|
info += "作業:" + data["執行項目"] + "\n"
|
|
|
info += "執行人員:" + data["指派對象"] + "\n"
|
|
|
info += "PM:" + data["PM"] + "\n"
|
|
|
- info += "執行期間:" + data["起始日"] + "-" + data["完成日"]
|
|
|
+ info += "預定執行期間:" + data["起始日"] + "-" + data["完成日"]
|
|
|
if(deltastart>0):
|
|
|
info += " (尚有"+ str(deltastart) + "天)\n\n"
|
|
|
elif(deltastart==0):
|
|
@@ -89,6 +95,9 @@ for data in records_data:
|
|
|
info += " (過期"+ str(deltastart).replace('-','') + "天)\n\n"
|
|
|
overdue_email_content[data["PM"]] += info
|
|
|
has_overdue[data["PM"]] = 1
|
|
|
+ if [data["PM"]]!=[data["指派對象"]]: #sometimes you have to do the task and you are the PM
|
|
|
+ overdue_email_content[data["指派對象"]] += info
|
|
|
+ has_overdue[data["指派對象"]] = 1
|
|
|
if data["PM"] != "Jared": #sometimes Jared is the PM
|
|
|
overdue_email_content["Jared"] += info
|
|
|
has_overdue["Jared"] = 1
|
|
@@ -108,8 +117,13 @@ for data in records_data:
|
|
|
else:
|
|
|
info += " (過期"+ str(deltaend).replace('-','') + "天)\n\n"
|
|
|
overdue_email_content[data["PM"]] += info
|
|
|
+ has_overdue[data["PM"]] = 1
|
|
|
+ if [data["PM"]]!=[data["指派對象"]]: #sometimes you have to do the task and you are the PM
|
|
|
+ overdue_email_content[data["指派對象"]] += info
|
|
|
+ has_overdue[data["指派對象"]] = 1
|
|
|
if data["PM"] != "Jared": #sometimes Jared is the PM
|
|
|
overdue_email_content["Jared"] += info
|
|
|
+ has_overdue["Jared"] = 1
|
|
|
message2 += info
|
|
|
|
|
|
except:
|
|
@@ -124,8 +138,8 @@ messages.append(message2)
|
|
|
|
|
|
print(has_overdue)
|
|
|
|
|
|
-#send_line(messages) #annotated to prevent unintentional trigger
|
|
|
-#send_email(emails, overdue_email_content, has_overdue)
|
|
|
+send_line(messages)
|
|
|
+send_email(emails, overdue_email_content, has_overdue)
|
|
|
|
|
|
'''notify_group(message)
|
|
|
time.sleep(5)
|