c = open_connection()
typ, data = c.select('INBOX')
typ, msg_ids = c.search(None, '(FROM "XXX#dfadfaf.com")') #SUBJECT "Your report contains no data"
msg_ids = msg_ids[0].split(' ')
####################################################################
#For each message---find the relevent data
####################################################################
for msg_fet in msg_ids:
typ, msg_data = c.fetch(msg_fet, '(RFC822)')
for response_part in msg_data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
|