title: JavaMailSender with Exception writing Multipart
body: <p>When I used JavaMailSender to send e-mail with attachment, It always failed and throw the exception below:</p>
  
  <pre class="lang-java prettyprint-override"><code>org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: IOException while sending message;
    nested exception is:
      java.io.IOException: Exception writing Multipart
  ; message exception details (1) are:
  Failed message 1:
  javax.mail.MessagingException: IOException while sending message;
    nested exception is:
      java.io.IOException: Exception writing Multipart
      at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1365)
      at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:462)
      at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:359)
      at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:354)
  </code></pre>
  
  <p>Here is my code</p>
  
  <pre class="lang-java prettyprint-override"><code>MimeMessage message = mailSender.createMimeMessage();
  try {
      MimeMessageHelper helper = new MimeMessageHelper(message, true);
      helper.setFrom(userName);
      helper.setTo(toAddress);
      helper.setSubject(subject);
      FileSystemResource file = new FileSystemResource(filePath);
      helper.addAttachment(file.getFilename(), file);
  } catch (Exception e) {
      log.error("oops..., ", e);
  }
  mailSender.send(message);
  </code></pre>