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)