Open kostiantynvoiku opened 6 years ago
Hy,
To avoid the error, i've just modify the Library in the src/ImpaLibrary/_init_.py file In the import section, i've add
import quopri
And I've modify the get_email_body method
def get_email_body(self, email_index):
"""Returns the decoded email body on multipart email message,
otherwise returns the body text.
Arguments:
- ``email_index``: An email index to identity the email message.
Examples:
| Get Email Body | INDEX |
"""
if self._is_walking_multipart(email_index):
print('multipart')
body = self.get_multipart_payload(decode=True)
else:
**raw_body = quopri.decodestring(self._imap.uid('fetch',
email_index,'(BODY[TEXT])')[1][0][1]).decode('utf-8')
body = message_from_string(raw_body)**
return body
I'm not sure that .decode('utf-8')
work in all the case !
For my own test, I've add a new function: get_email_header
def get_email_header(self, email_index):
"""Returns the decoded email header of the email message in a dictionary
Arguments:
- ``email_index``: An email index to identity the email message.
Examples:
| Get Email Header | INDEX |
"""
# decode('quoted-printable')
raw_header = quopri.decodestring(self._imap.uid('fetch',email_index,
'(BODY[HEADER])')[1][0][1]).decode('utf-8')
header = message_from_string(raw_header)
result = {}
result['From'] = header['From']
result['To'] = header['To']
result['Date'] = header['Date']
result['Subject'] = header['Subject']
result['Content-Type'] = header['Content-Type']
result['Content-Language'] = header['Content-Language']
result['Return-Path'] = header['Return-Path']
return result
Perhaps this solution might be pulled in the git ..
Getting the same issue, will give this workaround a try. Looks like it's a common problem...
Any working work-around or fix?
Hello there,
I'm getting this LookupError when I try to use
Get Links From Email
keyword:Output:
Is there a workaround for this please?