exchange发邮件

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

def Email(to, subject, body):
    creds = Credentials(
        username='a@live.com',
        password='password'
    )
    account = Account(
        primary_smtp_address='a@live.com',
        credentials=creds,
        autodiscover=True,
        access_type=DELEGATE
    )
    m = Message(
        account=account,
        subject=subject,
        body=HTMLBody(body),
        to_recipients = [Mailbox(email_address=to)]
    )
    m.send()

message = '''-----------测试------------<br>
测试1<br>
'''

Email("abd@bayin.com", "主题", message)

  

上一篇:element ui 表格可编辑功能


下一篇:剑指Offer刷题记录_Day22