Skip to content

Conversation

peritus
Copy link

@peritus peritus commented Jun 9, 2017

We're using Python 3.5 and we kept getting this error when parsing emails:

Documentation:	
Returns all links found in the email body from given email_index.
Start / End / Elapsed:	20170609 14:05:28.333 / 20170609 14:05:28.500 / 00:00:00.167
14:05:28.334	TRACE	Arguments: [ b'21' ]	
14:05:28.499	FAIL	LookupError: 'quoted-printable' is not a text encoding; use codecs.decode() to handle arbitrary codecs	
14:05:28.499	DEBUG	Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ImapLibrary/__init__.py", line 147, in get_links_from_email
    body = self.get_email_body(email_index)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ImapLibrary/__init__.py", line 135, in get_email_body
    decode('quoted-printable')

The attached code fixes that by using the codecs module [https://docs.python.org/3.6/library/codecs.html] to parse the quoted printable email bodies

Copy link

@AndyDeany AndyDeany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the same issue and was about to make this pull request myself. Thanks 😄. Hope this gets merged soon.

@AndyDeany
Copy link

@peritus Actually, I've noticed that for my emails, the encoding is 'latin-1' instead of 'utf-8'. Any chance you could add an encoding='utf-8' default parameter to the method and then change the decoding step to read:

body = decode(encoded_body, 'quopri_codec').decode(encoding)

Thanks,
Andrew

@rickypc
Copy link
Owner

rickypc commented Apr 7, 2018

Thank you, @peritus. Would you please fill in the CLA located here: https://goo.gl/forms/QMyqXJI2LM. Thanks.

@nhtua
Copy link

nhtua commented Nov 26, 2019

Is there any update since May 21?

@lasselindqvist
Copy link

Is there any update since May 21?

If you need this fix, you can try using
https://github.com/lasselindqvist/robotframework-imaplibrary2 / https://pypi.org/project/robotframework-imaplibrary2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants