title: python and imaplib: how to download attachment file given the id of the email
body: <p>By using the <code>search</code> query, I am able to get the ids of the all the emails. Now I want to download the attachments from those email. How can I implement that? Any advice would be appreciated, stuck here for a day!</p>
  
  <p>EDIT:
  This is the <code>search</code> query:</p>
  
  <pre><code>m = imaplib.IMAP4_SSL('imap.gmail.com')
  m.login(username, password)
  m.select('inbox')
  resp, data = m.uid('search', None, 'X-GM-RAW', 'has:attachment filename:xls')
  emailids = data[0].split()
  </code></pre>