使用Python调用OUTLOOK发邮件
import win32com.client as win32
import warnings
import sys
import pythoncom
reload(sys)
sys.setdefaultencoding('utf8')
warnings.filterwarnings('ignore')
Pythoncom.CoInitialize()
def sendmail():
sub = 'outlook python mail test'
body = 'my test\r\n my python mail'
outlook = win32.Dispatch('outlook.application')
receivers = ['xxx']
mail = outlook.CreateItem(0)
mail.To = receivers[0]
mail.Subject = sub.decode('utf-8')
mail.Body = body.decode('utf-8')
mail.Attachments.Add('C:\Users\xxx\Desktop\git_auto_pull_new.py')
mail.Send()
sendmail()
系统弹窗提醒。
收到邮件
OutLook选项——信任中心——信任中心设置——编程访问——从不向我发出可疑活动警告
相关文章