I'm trying to get a list of the subjects that I'm getting from emails in gmail.
I can get the subjects, but I can't seem to get them into a list. Here's my code so far:
#! usr/bin/env python import imaplib M=imaplib.IMAP4_SSL('imap.gmail.com', 993) M.login('email@example.com','password') M.select() typ, emails = M.search(None, 'ALL') subject =  for email in emails.split(): typ, subjects = M.fetch(email, '(BODY[HEADER.FIELDS (SUBJECT)])') print '%s' % subjects subject = subjects M.close() M.logout() print subject
The first print statement prints the subjects, but once I've added them to list 'subject', and try to print it, it only prints the last subject. I've tried changing the following lines:
subject = subjects to subject += subjects
but that adds the subjects to the list as individual characters, instead of a string.
I've been working on this one problem for over an hour now, and I know it's a very basic thing (at least I think it should be), yet I can't solve it.
Any help appreciated...