vladimarius / imapy

Imapy: Imap for Humans
230 stars 22 forks source link

add support for attachments #6

Closed woutervh closed 8 years ago

woutervh commented 9 years ago

Using imapy 1.0.3 on python 2.7.10:

there seem no way to access attachments?

for example when you have a pdf-file in attachment, the content-type is 'application/pdf', but in imapy/email_message.py only 'text/plain' and 'text/html' are handled.

woutervh commented 9 years ago

It seems easy to just add in imapy/email_message.py

                elif content_type == 'text/html':
                    # convert html
                    html = utils.b_to_str(part.get_payload(decode=True))
                    self['html'].append(html)
                else:
                    attachment = {'filename': part.get_filename(),
                                           'data': utils.b_to_str(part.get_payload(decode=True)),
                                           'content_type': content_type, }
                    self['attachments'].append(attachment)
woutervh commented 9 years ago

See my changes: https://github.com/WouterVH/imapy/commit/bacaf07b3179d3b48b9cdbae066a45488e54d5ab

vladimarius commented 8 years ago

Fixed in 1.1.0