0

When I'm searching an email account using imaplib I need to be able to search with variables to cycle through a large number of automated mail, but I'm getting different results between when I explicitly pass a string and when I pass a variable with that same string. Example:

>>> rv,data = M.search(None, 'SUBJECT','"Sucessful Migrations 2019-07-08"')
>>> data
[b'28']
>>> item = '"Successful Migrations 2019-07-08"'
>>> rv,data = M.search(None, 'SUBJECT',item)
>>> data
[b'']

How can I correctly pass my search criteria in a variable to get the desired result?

David Scott
  • 796
  • 2
  • 5
  • 22
  • turn on m.debug = 5, then run both commands and see what the difference in the command sent is. Also make sure you have the same folder selected. – Max Jul 17 '19 at 13:58
  • 1
    Thank you so much for causing me to stare at this for so long. The problem is that the email has Successful misspelled as Sucessful and the misspelling was not carried over to my template for generating email subjects. – David Scott Jul 17 '19 at 18:20
  • 1
    Ah, I didn't see it either. They both looked misspelled to me, but I see now they are different ;) – Max Jul 17 '19 at 18:22

0 Answers0