ezgmail
ezgmail copied to clipboard
KeyError 'headers'
I get a KeyError when trying to interact with any message and any function over unreadThreads (summary, unreadThreads[0].message....)
Traceback (most recent call last):
File "start.py", line 44, in <module>
logger.info(ezgmail.summary(unreadThreads))
File "path/to/venv/lib/python3.8/site-packages/ezgmail/__init__.py", line 704, in summary
(obj.senders(), obj.snippet, obj.latestTimestamp())
File "path/to/venv/lib/python3.8/site-packages/ezgmail/__init__.py", line 120, in senders
for msg in self.messages:
File "path/to/venv/lib/python3.8/site-packages/ezgmail/__init__.py", line 104, in messages
self._messages.append(GmailMessage(msg))
File "path/to/venv/lib/python3.8/site-packages/ezgmail/__init__.py", line 247, in __init__
for header in part["headers"]:
KeyError: 'headers'
I temporarly solved the issue by defaulting the encoding to utf8 if there are no headers to guess it:
In __init__.py
line 247
try:
for header in part["headers"]:
if header["name"].upper() == "CONTENT-TYPE":
emailEncoding = _parseContentTypeHeaderForEncoding(header["value"])
except:
emailEncoding = "utf8"