반응형
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/
반응형
'<개인공부> - IT > [Python]' 카테고리의 다른 글
복수개의 값 리스트에서 지우기 (None, multiple data remove in list) (0) | 2020.09.11 |
---|---|
Cisco ISE ERS API (Device Update) (2) | 2020.08.26 |
Openpyxl - Make a report template (0) | 2020.07.30 |
How to get a dict key in the list (0) | 2020.06.13 |
Python f-strings (Keep updating) (0) | 2020.04.04 |