I tried to send an e-mail using GNU JavaMail 1.1.1 in combination with
GNU Activation 1.1 with this simple code:
Session session = Session.getInstance(new Properties());
MimeMessage mm = new MimeMessage(session);
mm.setSender(new InternetAddress(sender));
mm.setRecipient(RecipientType.TO, new InternetAddress(recipient));
mm.setSubject(subject);
mm.setText(message);
Transport transport = session.getTransport("smtp");
transport.connect(host_, port_, "", "");
Address[] recipients = { new InternetAddress(recipient) };
transport.sendMessage(mm, recipients);
This led to the following exception:
javax.mail.SendFailedException: no object DCH for MIME type text/plain;
charset=UTF-8
at gnu.mail.providers.smtp.SMTPTransport.sendMessage(SMTPTransport.java:520)
Tracking down the problem I found this code in
javax.activation.ObjectDataContentHandler:
public void writeTo(Object object, String mimeType, OutputStream out)
throws IOException
{
if (dch != null)
{
dch.writeTo(object, mimeType, out);
}
throw new UnsupportedDataTypeException("no object DCH for MIME type " +
mimeType);
}
This method seems to have a bug because the exception gets thrown even
if dch is not null. Changing this method to following solved the
problem:
public void writeTo(Object object, String mimeType, OutputStream out)
throws IOException
{
if (dch == null)
throw new UnsupportedDataTypeException("no object DCH for MIME type " +
mimeType);
dch.writeTo(object, mimeType, out);
}
I hope this is useful to someone...
Markus
--
Always remember you're unique. Just like everyone else.
_______________________________________________
Classpathx-discuss mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpathx-discuss