title: Get the size of an attachment using IMAP on GMAIL
body: <p>I would like to retrieve the size of each mail's attachment without having to download the file to get it. I'm using the <a href="https://github.com/nu7hatch/gmail" rel="nofollow">Gmail gem</a>.</p>
  
  <p>EDIT: I'm looking for a way, to get the size only by reading the headers or similar without having to retrieve the whole attachments which is a very long process.</p>
  
  <pre><code>gmail = Gmail.connect(:xoauth, self.email, 
    :token           =&gt; self.token,
    :secret          =&gt; self.secret,
    :consumer_key    =&gt; 'SECRET',
    :consumer_secret =&gt; 'SECRET'
  )
  mails = gmail.mailbox("[Gmail]/All Mail").emails
  mails.each do |mail|
    next if mail.message.attachments.blank?
    # How to get the message's size if possible ?
    mail.message.attachments.each do |attachment|
      # How to get the attachment's size ?
    end
  end
  </code></pre>