title: UnsupportedDataTypeException: no object DCH for MIME type application/pkcs7-mime
body: <p>I am trying to create encrypted mail on Android, using:</p>
  
  <ol>
  <li>Javamail libs from <a href="http://code.google.com/p/javamail-android/downloads/list" rel="nofollow">here</a>,</li>
  <li>SpongyCastel libs Core-1.51.0.0.jar, pg-1.51.0.0.jar, pkix-1.51.0.0.jar, prov-1.51.0.0.jar &amp; scmail-jdk15on-1.47.0.3.jar.</li>
  </ol>
  
  <p>Below is the code [copied from spongycastel example source]:</p>
  
  <pre><code>MailcapCommandMap mailcap = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
  mailcap.addMailcap("application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature");
  mailcap.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime");
  mailcap.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature");
  mailcap.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
  mailcap.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");
  
  CommandMap.setDefaultCommandMap(mailcap);
  
  if (Security.getProvider("SC") == null) {
      Security.addProvider(new BouncyCastleProvider());
  }
  
  KeyStore ks = KeyStore.getInstance("PKCS12", "SC");
  ks.load(new FileInputStream("keystorefile.pfx"), "passwd".toCharArray());
  Enumeration e = ks.aliases();
  String keyAlias = null;
  while (e.hasMoreElements()) {
      String alias = (String) e.nextElement();
      if (ks.isKeyEntry(alias)) {
          keyAlias = alias;
      }
  }
  if (keyAlias == null) {
      System.err.println("can't find a private key!");
      System.exit(0);
  }
  Certificate[] chain = ks.getCertificateChain(keyAlias);
  SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
  gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator((X509Certificate) chain[0]).setProvider("SC"));
  MimeBodyPart msg = new MimeBodyPart();
  msg.setText("Hello world welcome!");
  MimeBodyPart mp = gen.generate(msg, new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC).setProvider("SC").build());
  Properties props = System.getProperties();
  Session session = Session.getDefaultInstance(props, null);
  Address fromUser = new InternetAddress("\"abc cdf\"&lt;abc.cdf@gmail.com&gt;");
  Address toUser = new InternetAddress("abc.cdf@gmail.com");
  MimeMessage body = new MimeMessage(session);
  body.setFrom(fromUser);
  body.setRecipient(Message.RecipientType.TO, toUser);
  body.setSubject("example encrypted message");
  body.setContent(mp.getContent(), mp.getContentType());
  body.saveChanges();
  body.writeTo(new FileOutputStream("/sdcard/smime.p7m"));
  </code></pre>
  
  <p>when it calls <code>body.writeTo()</code>, following exception is thrown. Please let me know how can I solve this issue:</p>
  
  <pre><code>javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/pkcs7-mime; name="smime.p7m"; smime-type=enveloped-data
  W/System.err( 7226):    at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:905)
  W/System.err( 7226):    at javax.activation.DataHandler.writeTo(DataHandler.java:330)
  W/System.err( 7226):    at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
  W/System.err( 7226):    at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745)
  W/System.err( 7226):    at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1721)
  W/System.err( 7226):    at com.agy.createmail.SignEncryptMail.createSignedEncryptedMail(EncryptMail.java:151)
  W/System.err( 7226):    at com.agy.createmail.MainActivity$CreateMailTask.doInBackground(MainActivity.java:32)
  W/System.err( 7226):    at com.agy.createmail.MainActivity$CreateMailTask.doInBackground(MainActivity.java:1)
  W/System.err( 7226):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
  W/System.err( 7226):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  W/System.err( 7226):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
  W/System.err( 7226):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  W/System.err( 7226):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  W/System.err( 7226):    at java.lang.Thread.run(Thread.java:841)
  </code></pre>