其他分享
首页 > 其他分享> > exchange发邮件

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)

  

标签:body,发邮件,exchange,account,address,message,com,subject
来源: https://www.cnblogs.com/pythonClub/p/15796198.html