Skip to content

Emails with attachments produce errors #36

@clay4shin

Description

@clay4shin

Hello, I'm following the book (Thank you for the amazing book, btw!) for ezgmail module.

I'm having an issue when I search emails with attachments and try to download it. The module seems to be able to search correct emails and save it to a thread object but when I try to read the summary of threads (ezgmail.summary(threads)) or try to access the attachments (threads[0]messages[0].attachments), it's showing me errors.

These are the codes and outputs I received from the terminal:

>>> import ezgmail
>>> threads = ezgmail.search('(now with attachment)')
>>> len(threads)
3
>>> ezgmail.summary(threads)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shinsooyun/Library/Python/3.9/lib/python/site-packages/ezgmail/__init__.py", line 704, in summary
    (obj.senders(), obj.snippet, obj.latestTimestamp())
  File "/Users/shinsooyun/Library/Python/3.9/lib/python/site-packages/ezgmail/__init__.py", line 120, in senders
    for msg in self.messages:
  File "/Users/shinsooyun/Library/Python/3.9/lib/python/site-packages/ezgmail/__init__.py", line 104, in messages
    self._messages.append(GmailMessage(msg))
  File "/Users/shinsooyun/Library/Python/3.9/lib/python/site-packages/ezgmail/__init__.py", line 273, in __init__
    attachmentId = part["body"]["attachmentId"]
KeyError: 'attachmentId'
>>> threads[0].messages[0].attachments
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shinsooyun/Library/Python/3.9/lib/python/site-packages/ezgmail/__init__.py", line 107, in messages
    assert len(self._messages) > 0, "GmailThread object has zero messages; please file a new bug report issue: https://github.com/asweigart/ezgmail/issues"
AssertionError: GmailThread object has zero messages; please file a new bug report issue: https://github.com/asweigart/ezgmail/issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions