待办事项微信定时提醒
微信的接口好久不调用,不知道是否已禁用。所以下段代码采用给对方qq邮箱发邮件发方式进行微信提醒(设置——通用——辅助功能——QQ邮箱提醒)。
# -*- coding:utf-8 -*-
# coding: utf-8 cp936
#@V1.0 Slim version without .ini
import os
import smtplib
import socket
import time
import threading
from email.message import Message
import email.utils
import ConfigParser
to_addr = ['564868230@qq.com','37878996@qq.com']
subject="[打卡提醒] Clock in/out Reminder"
content="Please Clock in/out, or you will lose your money. "
'''sendQQMsg'''
def sendMsg(to_addr,subject,content,time=''):
smtpserver = 'smtp.126.com'
username = 'n****lin'
password = 'wa****13'
from_addr = 'n****lin@126.com'
to_addr = to_addr
cc_addr = ''
#time = email.utils.formatdate(time.time(),True)##must mv out
message = Message()
message['Subject'] = subject
message['From'] = from_addr
message['To'] = ",".join( to_addr )
message['To']
message['Cc'] = cc_addr
message.set_payload(content+'\n'+time)
msg = message.as_string()
sm = smtplib.SMTP(smtpserver,port=25,timeout=20)
sm.login(username, password)
sm.sendmail(from_addr, to_addr, msg)
'''Main'''
if __name__ == '__main__':
for i in range(3):
print "Start : %s" % time.ctime()
sendMsg(to_addr,str(i)+subject,content,time='')
print "End : %s" % time.ctime()
time.sleep( 10 )
网友评论