首页 > 编程语言 > 详细

Python发送Exchange邮件

时间:2021-06-22 15:11:41      阅读:10      评论:0      收藏:0      [点我收藏+]

安装exchangelib

参考:https://pypi.org/project/exchangelib/

pip install exchangelib

发送邮件集附件

from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials, Message, HTMLBody, Mailbox, FileAttachment

account = Account(‘***@***‘,
                  credentials=Credentials(username=‘***@***‘, password=‘***‘),
                  autodiscover=True)

m = Message(
        account=account,
        subject=‘测试带附件下‘,
        body=HTMLBody(‘<h2>hello with attachment</h2>‘),
        to_recipients=[Mailbox(email_address=‘superhin@126.com‘)]
    )

m.attach(FileAttachment(name=‘test.html‘, content=open(‘/result/test.html‘,‘rb‘).read()))
m.send()

Python发送Exchange邮件

原文:https://www.cnblogs.com/superhin/p/14917951.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!