Python发送Exchange邮件
安装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()