Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

No Content Error when sending mail

843830Feb 28 2002 — edited Jan 10 2008
Given this code:

Properties props = System.getProperties();
String host = "mail.myhost.com";
props.put("mail.smtp.host", host);
Session msession = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(msession);
message.setSubject("The information you requested");
message.setFrom(new InternetAddress("from@myhost.com"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("to@myhost.com"));
BodyPart messageBodyPart = new MimeBodyPart();
String messageText = "blah";
messageBodyPart.setText(messageText);
Transport.send(message);

I get the following exception:

javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.IOException: No content
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)

any clues?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 7 2008
Added on Feb 28 2002
6 comments
10,115 views