Hi,

I'm trying to send an email with images within an osgi component.

But I'm getting the following error when trying to send an email.

*javax.mail.MessagingException: IOException while sending message;*
*  nested exception is:*
* javax.activation.UnsupportedDataTypeException: no object DCH for MIME
type multipart/related; *
* boundary="----=_Part_0_765083650.1473940691764"*
* at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:625)*
* at javax.mail.Transport.send0(Transport.java:169)*
* at javax.mail.Transport.send(Transport.java:98)*

After some search and trial & error I figured out this issue is due to the
use of javax.activation as an imported package.

I checked the bundle dependencies and following is the details about the
bundle.

* Imported packages*
*    javax.activation;
version="0.0.0"<org.eclipse.osgi_3.9.1.v20130814-1242 [0]>*


I have tried the following to solve the issue.

1. Add following line before sending. According to [1]

Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );

2. Add following. According to [1]

MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;;
x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;;
x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;;
x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;;
x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-
handler=com.sun.mail.handlers.message_rfc822");


I cannot figure out what the exact problem is and any help is appreciated.

p.s. I have a working standalone java class which is succesfully sending
emails with attachments and uses the javax activation from
activation-1.1.1.jar

[1] 
http://stackoverflow.com/questions/21856211/javax-activation-unsupporteddatatypeexception-no-object-dch-for-mime-type-multi

-- 
Fathima Dilhasha
*Software Engineer*
Mobile : +94 (0) 771663314 <%2B94%20%280%29%20773655496>
<%2B94%20%280%29%20773%20451194>
[email protected] <[email protected]>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to