<개인공부> - IT/[Python]
Basic usage exchangelib (MS Exchange)
Aggies '19
2020. 8. 1. 03:57
반응형
MS Exchange is a intergrated software for email, calendar, tasks, and etc.
There are many features that we can use. But this time, I introduce a basic usage of exchagelib with Python. Especially sending an email with an attachment.
from exchangelib import *
credentials = Credentials(username='yourusername', password='yourpassword')
account = Account(primary_smtp_address='youremailaddress', credentials=credentials, \
autodiscover=True, access_type=DELEGATE)
bodyContents = """ISE's device list audit has been conducted.
Please check the attachment"""
m = Message(account=account, subject='[ISE-Audit] ISE Device Audit', body=bodyContents,
to_recipients=[Mailbox(email_address='recipient_email_address')])
filePath = open('ISE_Device_Audit.xlsx', 'rb').read()
m.attach(FileAttachment(name='ISE_Device_Audit.xlsx', content=filePath))
m.send()
Reference site: https://pypi.org/project/exchangelib/
반응형