title: Find the subject of a specific email - imap -python
body: <p>I need to find an email whose subject is 'Reset Password' from a particular sender named - xteam and then do some further actions with that mail</p>
  
  <p>If I do this:</p>
  
  <pre><code> imap_host = 'imap.gmail.com'
   imap_user = 'abc@gmail.com'
   imap_pass = 'pass113'
  
   imap = imaplib.IMAP4_SSL(imap_host)
  
   imap.login(imap_user, imap_pass)   
   status, message = imap.search(None, '(SUBJECT "Reset Password")')
  </code></pre>
  
  <p>There are many other senders in addition to xteam who have sent emails with 'Reset Password' subject</p>
  
  <p>then I tried:</p>
  
  <pre><code> status, message = imap.search(None, '(FROM "help@xteam.com")')
  </code></pre>
  
  <p>but xteam has sent many other irrelevant emails</p>
  
  <p>Lastly:</p>
  
  <pre><code> status, message = imap.search(None, '(AND (FROM "help@xteam.com") (SUBJECT "Reset Password"))')
  </code></pre>
  
  <p>This gives error:</p>
  
  <p>imaplib.IMAP4.error: SEARCH command error: BAD [b'Could not parse command']</p>
  
  <p>Which is the best possible way to do it.</p>