Java Mail MIMEMessage getSize() returns -1
<p>I am having a simple error:
I create a MIMEMessage, set the subject, recipients, and content as MimeMultipart. The MimeMultipart has several MimeBodyPart's, as attachments to the email message. When I want to check the message size in order to see if it is larger than the permitted 25MB attachment size in Gmail, the getSize() method always returns -1. It should be simple, but I'm stumped! I have run several test cases and they all fail here. EX:</p>

<pre><code>if(attachments!=null &amp;&amp; attachments.length&gt;0)
{
    MimeBodyPart textPart = new MimeBodyPart();
    System.out.println("    &gt;Adding Text");
    textPart.setText(body);

    MimeBodyPart[] attachmentParts = new MimeBodyPart[attachments.length];
    int iii=0;
    for(String s : attachments)
    {
        System.out.println("    &gt;Adding Attachment " + (iii+1));
        MimeBodyPart bp = new MimeBodyPart();
        bp.attachFile(s);
        attachmentParts[iii] = bp;
        iii++;
    }

    MimeMultipart mp = new MimeMultipart();

    mp.addBodyPart(textPart);

    for(MimeBodyPart bp : attachmentParts)
        mp.addBodyPart(bp);

    msg.setContent(mp);
}
else 
{
    System.out.println("    &gt;Adding Text");
    msg.setText(body);
}

//determine the size of message

msg.saveChanges();
System.out.println("++++++done creating message: ");
bytes = msg.getSize();

System.out.println("MESSAGE SIZE: " + bytes+ "\nGMAIL LIMIT: " + GMAIL_MESSAGE_SIZE_LIMIT_B);

if(bytes&gt;GMAIL_MESSAGE_SIZE_LIMIT_B)
    throw new IllegalArgumentException("The message size ("+bytes/1000.0
                                               +" MB) is bigger than the allowed gmail size of "
                                               +GMAIL_MESSAGE_SIZE_LIMIT_B/1000.0 +" MB" );
</code></pre>

<p>I have already tried writing it to an output stream and getting the size of that, but it required that I adjust the amount of memory that JVM can use...i simply attached one 2.8 MB picture and the output stream reported that the message was some 30+ GB, which is wrong by powers of 10!</p>

<p>All i want is the size of my message :( any help would be great!</p>
