No Content Error when sending mail
843830Feb 28 2002 — edited Jan 10 2008Given 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?