title: Java Mail: Converting attachment data failed
body: <p>I want to send Files using Java Mail, I have the next code:</p>
  
  <p>Here I download the file from Google Drive in InputStream.</p>
  
  <pre><code>File file = DriveHelper.getFile("oalsdiañsdluioumadsspdmaasd-asdoiasd");
  InputStream inputStream = DriveHelper.downloadFile(file);
  </code></pre>
  
  <p>After that I write the next code:</p>
  
  <pre><code>Message message = new MimeMessage(session);
  String htmlBody = "hello world";        // ...
  // convert inputstream to byte[]
  byte[] attachmentData = IOUtils.toByteArray(inputStream);
  
  Multipart mp = new MimeMultipart();
  
  MimeBodyPart htmlPart = new MimeBodyPart();
  htmlPart.setContent(htmlBody, "text/html");
  mp.addBodyPart(htmlPart);
  
  MimeBodyPart attachment = new MimeBodyPart();
  attachment.setFileName("archivo.pdf");
  attachment.setContent(attachmentData, "application/pdf");
  mp.addBodyPart(attachment);
  message.setContent(mp);
  Transport.send(message);
  </code></pre>
  
  <p>But when I run the code I have next Exception: </p>
  
  <pre><code>javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Converting attachment data failed)
  [INFO]  at javax.mail.Transport.send(Transport.java:163)
  [INFO]  at javax.mail.Transport.send(Transport.java:48)
  </code></pre>