Python IMAP - search by headers

698 Views Asked by At

I am using Python's IMAPClient in my mail client, and basically I am stuck trying to look up messages by their headers. Specifically, I am trying to find all messages with a given in_reply_to value, which is part of ENVELOPE.

I have tried the following, but none of them works.

server.select_folder(folder_name)
server.search(['ENVELOPE[IN_REPLY_TO]', 'my_target_value'])
#server.search(['ENVELOPE.IN_REPLY_TO', 'my_target_value'])
#server.search(['IN_REPLY_TO', 'my_target_value'])

Any ideas how to do that?

0

There are 0 best solutions below