0
m = imaplib.IMAP4_SSL('imap.gmail.com')
typ, accountDetails =m.login(userName, passwd)
m.select("inbox")
resp, data = m.search(None, "(ON {0})".format( time.strftime("%d-%b-%Y") ),'(FROM "email")' )
print(resp)
print(data)

This gives me the output:

OK
[b'6391 6395']

So I assume 'OK' means it found an email but I'm not sure what the ' [b '6391 6395'] means. What do those numbers represent?

Sorath
  • 543
  • 3
  • 10
  • 32

1 Answers1

0

imaplib does not really parse responses, so you're getting a fairly raw response from the library. The OK is the overall response to the command, which means that the server understood your request.

Each line of the response is returned as an item in a list. SEARCH only returns one line, so you have a list of one item. Since imaplib does not do any parsing, you are getting the text of that response in it's original format: a bytes object of space separated numbers, representing Message Sequence Numbers.

You should be able to get a list of MSNs with msns = data[0].split(b' ').

You can then loop over this list to obtain further information, for example:

for msn in msns:
  resp, data = m.fetch(msn, '(RFC822)')
Max
  • 10,701
  • 2
  • 24
  • 48