title: JavaMail - Attachment filename not displaying UTF-8 characters correctly
body: <p>I am trying to send mails that may contain UTF-8 characters in subject, message body and in the attachment file name.</p>
  
  <p>I am able to send UTF-8 characters as a part of Subject as well as Mesage body. However when I am sending an attachment having UTF-8 characters as a attachment file name, it is not displaying it correctly.</p>
  
  <p>So my question is how can I set attachement filename as UTF-8?</p>
  
  <p>Here is part of my code:</p>
  
  <pre><code>MimeBodyPart pdfPart = new MimeBodyPart();
  pdfPart.setDataHandler(new DataHandler(ds));
  pdfPart.setFileName(filename);
  mimeMultipart.addBodyPart(pdfPart);
  </code></pre>
  
  <p>Later edit: </p>
  
  <p>I replaced </p>
  
  <pre><code>pdfPart.setFileName(filename);
  </code></pre>
  
  <p>with</p>
  
  <pre><code>pdfPart.setFileName(MimeUtility.encodeText(filename, "UTF-8", null));
  </code></pre>
  
  <p>and it is working perfectly. 
  Thanks all.</p>