jaesson1985
jaesson1985

Reputation: 748

how can I save an attachment using exchangelib

using Anaconda2-5.0.0-Windows-x86_64, Python2.7, exchangelib 1.10.4

I am trying to save attachments from all emails from an exchange account. It seems I can connect to the account without problem but everytime I try to run through the process, it gives me an error message. Here is the code which I have tried :

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 error I am getting is :

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.

The messages on that inbox contain CSV file attachments and the mailbox currently has 23 messages stored.

Upvotes: 2

Views: 4392

Answers (1)

Related Questions