【问题标题】:How to get all mails from MS exchange in Python?如何在 Python 中从 MS Exchange 获取所有邮件?
【发布时间】:2016-08-16 02:57:26
【问题描述】:

我想查看我在 MS Exchange/OWA 上收到的所有邮件。有没有办法使用 Python 做到这一点?

我确实在C#/Java 中看到了一些解决方案。

但是我如何在 Python 中做到这一点? 类似的问题是Connect to exchange with python,但我不明白该怎么做。

【问题讨论】:

  • 您找到解决方案了吗?
  • @ebertbm 不是一个完整的解决方案。你有吗?
  • 我还在找。

标签: python email exchange-server-2010


【解决方案1】:

我维护的 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)

【讨论】:

  • 为什么它对我不起作用,在创建帐户对象时抛出错误。
  • 没有错误消息或堆栈跟踪就无法判断。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-14
  • 2013-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多