title: Some gmail message attachments return ValueError for some reason
body: <p>This is the code. (<code>cred.py</code> is a file containing my password and username)</p>
  <pre class="lang-py prettyprint-override"><code>import os
  from os.path import dirname,realpath
  from imbox import Imbox 
  import imaplib
  import traceback
  import datetime
  from cred import *    # contains username and password
  def main():
      p = dirname(realpath(__file__))
      host = &quot;imap.gmail.com&quot;
      download_folder = p+&quot;\\&quot;+username+&quot;\\&quot;+str(datetime.datetime.now())[:10]
      if not os.path.isdir(download_folder):
          os.makedirs(download_folder, exist_ok=True)
      mail = Imbox(host, username=username, password=password, ssl=True, ssl_context=None, starttls=False)
      messages = mail.messages(unread=True) # defaults to inbox
  
      for (uid, message) in messages:
         mail.mark_seen(uid) # optional, mark message as read
         for idx, attachment in enumerate(message.attachments):
              try:
                  att_fn = attachment.get('filename')
                  download_path = f&quot;{download_folder}\\{att_fn}&quot;
                  print(download_path)
                  with open(download_path, &quot;wb&quot;) as fp:
                      fp.write(attachment.get('content').read())
              except:
                 print(traceback.print_exc())
  
      mail.logout()
  if input('Enter &quot;test&quot; to run now, else to run at 00:00 ') == 'test':
      main()
  
  while True:
      if str(datetime.datetime.now())[11:-7] == &quot;00:00:00&quot;:
          print('running')
          main()
  </code></pre>
  <p>For some reason some messages raise a <code>ValueError</code> and it looks like a bug in module. What do I do?</p>