Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions gmail/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def __init__(self, mailbox, uid):
self.thread_id = None
self.thread = []
self.message_id = None

self.attachments = None



def is_read(self):
Expand Down Expand Up @@ -166,13 +166,21 @@ def parse(self, raw_message):
if re.search(r'X-GM-MSGID (\d+)', raw_headers):
self.message_id = re.search(r'X-GM-MSGID (\d+)', raw_headers).groups(1)[0]


# Parse attachments into attachment objects array for this message
self.attachments = [
Attachment(attachment) for attachment in self.message._payload
if not isinstance(attachment, basestring) and attachment.get('Content-Disposition') is not None
]

self.attachments = []
def make_attachement(attachments):
for attachment in attachments:
if attachment.get_content_type() == 'message/rfc822':
make_attachement(attachment.get_payload())
else:
if not attachment.is_multipart():
self.attachments.append(Attachment(attachment))
else:
make_attachement(attachment.get_payload())

make_attachement(self.message.get_payload())


def fetch(self):
if not self.message:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read(fname):

setup(
name = "gmail",
version = "0.0.5",
version = "0.0.6",
author = "Charlie Guo",
author_email = "FIXME",
description = ("A Pythonic interface for Google Mail."),
Expand Down