KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to get the size of a MimeMessage. The method getSize() simply always returns -1. This is my code: MimeMessage m = new MimeMessage(session); m.setFrom(new InternetAddress(fromAddress, true)); m.setRecipient(RecipientType.TO, new InternetAddress(toAddress, true)); m.setSubject(subject); MimeBodyPart bodyPart = new MimeBodyPart(); bodyPart.setContent(body, "text/html"); Multipart mp = new MimeMultipart(); mp.addBodyPart(bodyPart); m.setContent(mp); m.getSize(); // -1 is returned THIS IS THE ANSWER TO MY QUESTION: ByteArrayOutputStream os = new ByteArrayOutputStream(); m.writeTo(os); int bytes = os.size();
Tags (comma-separated)
Save Edits
Cancel