response = server.fetch(messages, ['RFC822'])
for msgid, data in response.items():
    msg_string = data['RFC822']
msg = email.message_from_string(msg_string)
print('ID %d: From: %s Date: %s' % (msgid, msg['From'], msg['date']))
Download a specific email from Gmail using Python