title: How do I search email with rfc822msgid:
body: <p>I receive an error whenever I try to search my inbox using rfc822msgid with python2 and imaplib.  The following is an example of the code I use to find a specific email...</p>
  
  <pre><code>"rfc822msgid:{msg_id}".format(msg_id=searchtool).replace("\n", "")
  </code></pre>
  
  <p>The variable <code>searchtool</code> is the proper message-id from the email I am looking for.  I was able to verify that by going onto google's gmail webpage and typing in the exact same command in their search box to get the email I am looking for back from the search query.  However, when I try to do this through imaplib in python2 I get this error:</p>
  
  <pre><code>raise self.error('%s command error: %s %s' % (name, typ, data))
  imaplib.error: SEARCH command error: BAD ['Could not parse command']
  </code></pre>
  
  <p>So far I have tried putting double quotes around the whole search query and around the message-id and I still get the exact same error.  If one of you could please show me how to fix this that would be greatly appreciated. I have spent 2 days looking on google trying to figure out why I get this error, but I am hopeful that one of you may be able to help me out.</p>