我想查看我在MS Exchange / OWA上收到的所有邮件。有没有办法用Python做到这一点?
但我怎么能用Python做呢? 类似的问题是Connect to exchange with python,但我无法理解如何做到这一点。
答案 0 :(得分:14)
我维护的Python EWS包(https://pypi.python.org/pypi/exchangelib)支持这一点。这是一个简单的例子:
from exchangelib import DELEGATE, Account, Credentials
creds = Credentials(
username='MYWINDOMAIN\myusername',
password='topsecret')
account = Account(
primary_smtp_address='john@example.com',
credentials=creds,
autodiscover=True,
access_type=DELEGATE)
# Print first 100 inbox messages in reverse order
for item in account.inbox.all().order_by('-datetime_received')[:100]:
print(item.subject, item.body, item.attachments)