Hi,

I try to send a Multipart email in a simple java method, using Javamail.
When i use the method in a local java app, everything is fine.
When i use the same method in a webapp hosted by Tomcat, 
i got no message, but a file "noname" in attachment.

Here is the method :

public void sendTestMultipartMail(String host, final String username, final String password, String from, String to) throws Exception {

Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.port", "587");
 
Session session = Session.getInstance(properties,
 new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
 });
 
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject("Test MultiPart Mail");

Multipart multipart = new MimeMultipart();

BodyPart part1 = new MimeBodyPart();
part1.setText("This is multipart mail and u read part1......");

BodyPart part2 = new MimeBodyPart();
part2.setText("This is multipart mail and u read part2......");

multipart.addBodyPart(part1);
multipart.addBodyPart(part2);

msg.setContent(multipart);

Transport.send(msg);
}

And here are the results (i use gmail) :

Images intégrées 1

The first (and wrong) email came from the Tomcat server.
It has no message, and an attachment with "noname" name.
The other email is good and came from my java app.

Thanks in advance,
Jacques