If the attachment filename includes non-ASCII characters, how do I encode the name so that the name comes across appropriately?

John Zukowski

You need to get the string as bytes and then encode the filename yoruself. In addition, you have to do the same for the content type and disposition:

String name = new String(fileName.getBytes());
name = MimeUtility.encodeText(name, "ISO-2022-JP", "B" );
   "Content-Type: application/x-Semail; name=""+ name + """);
   "attachment; filename="" + MimeUtility.encodeText(name, "ISO-2022-JP", "B" )  + """);