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 'ex@ex.com' 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))
My editor removed trailing spaces, sorry 'bout that.
Example usage: