Recently i have follow the Sun online guide on Java Mail API to send email, download email and download attachment. When comes to extracting attachment from an email, my code looks very similar to this post Download attachments using Java Mail
However, i encounter a problem when the user send the email attachment file name with vietnamese character, something like this: hệ thống thông.xls
When the code tries to get the filename with: bodyPart.getFileName() , the return file name is like this: h? th?ng =?iso-8859-1?b?dGj0bmcueGxz?=
I have try the following but without any luck
1) set Java VM parameter: -Dfile.encoding=UTF-8
2) try to look further into the Java Mail API on UTF-8 Character support, but cant find any
Any hint will help. Thank you!
ISO-8859-1 is the Latin-1 character set. It only includes Western European characters. So that might be a hint. Maybe the problem is with the client that’s sending the attachment? Take a look at the raw source for the message, check if any of the headers say anything about the text encoding.