title: Jave : email with pdf attached file : no object DCH for MIME type application/pdf
body: <p>I want to send a pdf file in an email with javax mail.<br>
  Below, baos is a ByteArrayOutputStream.</p>
  
  <pre><code>byte []  data=   baos.toByteArray();
  OutputStream output = new FileOutputStream(fileName);
  output.write(data);     
  output.close();
  DataSource source = new FileDataSource(fileName);
  attachBodyPart.setDataHandler(new DataHandler(source, "application/pdf"));
  attachBodyPart.setFileName(fileName);
  multipart.addBodyPart(attachBodyPart);
  message.setContent(multipart, "text/html");
  Transport transport = session.getTransport("smtp");
  transport.connect(host, from, pass);
  transport.sendMessage(message, message.getAllRecipients());
  transport.close();
  </code></pre>
  
  <p>I am getting this exception when I try to send the email : </p>
  
  <blockquote>
    <p>javax.mail.MessagingException: IOException while sending message;<br>
    nested exception is:  javax.activation.UnsupportedDataTypeException:
    no object DCH for MIME type application/pdf</p>
  </blockquote>
  
  <p>I don't know what's wrong here.<br>
  If someone does...</p>
  
  <p>Thanks in advance.</p>