pip install pip install pywin32

import os
import win32com.client as win32
import datetime

subject = "test"
app = "swds"
addressee = "xx@xx.com"
cc = ""
main_path = os.path.join("C:/swds/",'report.txt')

class send_email():
    def outlook(self):
        outlook = win32.Dispatch("Outlook.Application")
        mail = outlook.CreateItem(0) 
        mail.To = addressee
        #mail.CC = cc
        mail.Subject = str(datetime.datetime.now())[0:19]+'%s' %subject
        content = """
        执行测试中完成......
        测试已完成......
        生成报告中......
        报告已生成......
        报告已邮件发送......
        """
        mail.Body = content
        mail.Send()

if __name__ == '__main__':
    send_email().outlook()
    print("send email ok!!!!!!")

标签: none

添加新评论