Note that there are some explanatory texts on larger screens.

plurals
  1. POIMAP search for email address in the from field
    text
    copied!<p>I am trying to search and filter my imap mails using python's imaplib. I am running into a quite strange problem with the search command, searching for email addresses in the <code>FROM</code> field. I have the following script,</p> <pre><code>print('search with name') status, results = con.search(None, '(FROM "Shrikant Sharat")') if status == 'OK': if results[0]: mid = results[0].split()[0] print('mail id', mid) print(con.fetch(mid, '(UID BODY[HEADER.FIELDS (FROM)])')) else: print('No results yielded') else: print('unable to search', results) print() print('search with email') status, results = con.search(None, '(FROM "shrikantsharat.k@gmail.com")') if status == 'OK': if results[0]: mid = results[0].split()[0] print('mail id', mid) print(con.fetch(mid, '(UID BODY[HEADER.FIELDS (FROM)])')) else: print('No results yielded') else: print('unable to search', results) </code></pre> <p>for which, I get the following result,</p> <pre><code>search with name mail id 2155 ('OK', [('2155 (UID 5340 BODY[HEADER.FIELDS (FROM)] {54}', 'From: Shrikant Sharat &lt;shrikantsharat.k@gmail.com&gt;\r\n\r\n'), ' FLAGS (\\Seen))']) search with email No results yielded </code></pre> <p>Why does the second search fail? The email address is present in the <code>From</code> field as shown by the previous search. The second search should've matched this mail right?</p> <p>Is this not the way to search for email address in the <code>From</code> field? I am pulling my hair apart on this one. Any ideas?</p> <p><strong>Edit</strong> If relevant, I am trying this with an IMAP server exposed by MS Exchange (2007, I think).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload