-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'list' object has no attribute 'encode' #1
Comments
get_payload() returns either a list or string, I thought that in this part of the code only str would be returnable, but it may depend on the mail server and/or the sender mail server. I tested extensively with Gandi, Zimbra, and Gmail servers ; but I don't have access to other ones. Without access to the mail or the server provoking the error I will have a hard time debugging. Could you try to replace if isinstance(part.get_payload(), list):
attachment_content = part.get_payload(1).encode("utf-8")
else:
attachment_content = part.get_payload().encode("utf-8") But I'm not sure about using only the first part of the payload in this instance ; it could prevent the handling of multiple attachments. |
You can checkout the develop branch to try this solution. |
Thank you.
And it worked pretty well for about 14Gb (on a 20Gb Gmail account). But it fails again somewhere else, and I gave up (sorry). |
No problem, thanks for testing anyway ! It's a pain to develop a tool for mail handling as the protocol is implemented differently by almost every servers. So I got it working for the few servers I use, but it may not be ok for others. |
Extracted 3 attachments, replacing email.
Append message on IMAP server.
Delete original message.
Traceback (most recent call last):
File "/home/pengu/aurore/imap-attachment-extractor/.env/bin/imap_aex", line 11, in
load_entry_point('imap-attachment-extractor', 'console_scripts', 'imap_aex')()
File "/home/pengu/aurore/imap-attachment-extractor/imap_aex.py", line 824, in cli
main(options, defaults)
File "/home/pengu/aurore/imap-attachment-extractor/imap_aex.py", line 816, in main
imap.extract(**extract_kwargs)
File "/home/pengu/aurore/imap-attachment-extractor/imap_aex.py", line 493, in extract
attachment_content = part.get_payload().encode("utf-8")
AttributeError: 'list' object has no attribute 'encode'
The text was updated successfully, but these errors were encountered: