Skip to content

Conversation

rasa
Copy link
Contributor

@rasa rasa commented Apr 21, 2022

My editor removed trailing spaces, sorry 'bout that.

Example usage:

from simplegmail import Gmail

gmail = Gmail()

messages = gmail.get_unread_inbox()

message = messages[0]
if message.attachments:
    for attm in message.attachments:
        print('File: ' + attm.filename)
        if '[email protected]' in attm.headers.get('From'):
            attm.save()  # downloads and saves each attachment under its name
        for k, v in attm.headers.items():
            # RFC 5322 allows for duplicate header keys. See https://www.rfc-editor.org/rfc/rfc5322#section-3.6
            if isinstance(v, list):
                v = ', '.join(v)
            print('%s: %s' % (k, v))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant