Encoding attachment filenames
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   John_Zukowski
Posted On:   Monday, June 25, 2001 12:42 PM

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

Re: Encoding attachment filenames

Posted By:   John_Zukowski  
Posted On:   Monday, June 25, 2001 12:46 PM

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" );
mimeBodyPart.addHeaderLine(
"Content-Type: application/x-Semail; name=""+ name + """);
mimeBodyPart.addHeader(
"Content-Disposition",
"attachment; filename="" + MimeUtility.encodeText(name, "ISO-2022-JP", "B" ) + """);
About | Sitemap | Contact