调用outlook发邮件

 

import win32com.client as win32
import pythoncom

pythoncom.CoInitialize()


def send_mail(**kwargs):
    outlook = win32.Dispatch('Outlook.Application')
    reciList = ['1@1.com', '2@2.com']
    for i in range(len(reciList)):
        mail_item = outlook.CreateItem(0)  # 0: olMailItem
        mail_item.Recipients.Add(reciList[i])
        mail_item.Subject = 'Mail Test'
        mail_item.BodyFormat = 2  # 2: Html format
        mail_item.HTMLBody = '''
            <H2>Hello, This is a test mail~~.</H2>
            Hello Guys. '''

        # mail_item.Attachments.Add('d:\doc\IT Info.xlsx')
        mail_item.Send()


if __name__ == '__main__':
    send_mail()

  

上一篇:springBoot 定时+发送邮件


下一篇:存储型xss