Hello folks, i have issue with attach pdf in e-mail using two lib´s: activation.jar and mail.jar. Currently using a platform SOA and am creating the serviceType, then a file don´t is local and yes by message, so far so good.
Already tried in several forums, but without success.
When send the message (pdf file), the program receive a type ContentType (application/octet-stream) and cause the MessageException, below:
MessageException - in Container:
Message: [B@79ffb7f7 /// the service received the pdf file
[09/03/02 12:22:45] ID=dev_ESBTest (info)
application/octet-stream *///ContentType of message*
javax.mail.SendFailedException: Sending failed; *///Exception*
nested exception is:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
**javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream**
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream
at com.sun.mail.smtp.SMTPTransport.sendMessage (SMTPTransport.java:353)
at javax.mail.Transport.send0 (Transport.java:164)
at javax.mail.Transport.send(Transport.java:81)
....
With this, it send the e-mail without attach......above my source simple source code.
ServiceType Code:
protected void SendEmail(XQPart prt, String host, String from, String to) {
// create some properties and get the default Session
Properties props = System.getProperties();
props.put("mail.smtp.host";, host);
Session session = Session.getInstance(props, null);
try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test Subject.");
MimeBodyPart bp1 = new MimeBodyPart();
bp1.setText("Test Text.");
MimeBodyPart bp2 = new MimeBodyPart();
m_xqLog.logInformation(prt.getContentType());
bp2.setContent(prt.getContent(), prt.getContentType());
bp2.setFileName("teste.pdf";);
Multipart mp = new MimeMultipart();
mp.addBodyPart(bp1);
mp.addBodyPart(bp2);
msg.setContent(mp);
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("Email sent successfully!");
} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}
}
}
Anybody would can help me, please....
Thanks ....
Paulo Sampei.