I\'ve a problem of downloading arabic attachment files using java mail.
The file name is always ambiguous.
The problem is the Bodypart retrieve
The header is encoded according to the mechanism described in RFC 2047 (it's the encoded-word) which says that a section of a header matching =??B??= is a byte-encoded section. The B style, not the Q style) the
This is all rather complex. Luckily, you can deal with this easily by using the static javax.mail.internet.MimeUtility.decodeText() method. That means you can switch to this:
String filename = MimeUtility.decodeText(bodyPart.getFileName());
Actually, you're better off combining that with the next line too as well:
File f = new File("C:\\Attachments",
MimeUtility.decodeText(bodyPart.getFileName()));
It's better because it avoids more trouble with building filenames than trying to do it all by hand. (It also means that you can factor out that literal pathname into some configuration location.)