如何使用 exchangelib 保存附件

how can I save an attachment using exchangelib

使用 Anaconda2-5.0.0-Windows-x86_64,Python2.7,exchangelib 1.10.4

我正在尝试保存来自交换帐户的所有电子邮件的附件。似乎我可以毫无问题地连接到该帐户,但每次我尝试 运行 通过该过程时,它都会给我一条错误消息。这是我试过的代码:

mailbox = account.inbox

for msg in mailbox.all():
    for attachment in msg.attachments:
        fpath = os.path.join(r'C:\temp', attachment.name)
        with open(fpath, 'wb') as f:
            f.write(attachment.content)

我得到的错误是:

The 'FieldURI' attribute is invalid - The value 'item:IsAssociated' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:UnindexedFieldURIType' - The Enumeration constraint failed.

该收件箱中的邮件包含 CSV 文件附件,该邮箱当前存储了 23 封邮件。

这是连接到 Exchange 2007 服务器时 exchangelib 中的错误。固定在 https://github.com/ecederstrand/exchangelib/commit/8561bd0f3e6bfd7c8d01bc57cbcc3dca3cf33fc4 and https://github.com/ecederstrand/exchangelib/commit/3609fa23e403821bdc5f80cd896a9df1d73f0275