I am having trouble decrypting the email attachment file name. I am currently using JavaMail 1.4.2. The file is called "Żółw.rtf" (this is polishing for Turtle.rtf). Mail is sent using Mail.app (which seems very significant). Important headings are:
--Apple-Mail-19-721116558 Content-Disposition: attachment; filename*=utf-8''Z%CC%87o%CC%81%C5%82w.rtf Content-Type: text/rtf; x-unix-mode=0644; name="=?utf-8?Q?Z=CC=87o=CC=81=C5=82w=2Ertf?=" Content-Transfer-Encoding: 7bit
The corresponding javax.mail.Part.getFileName () returns "=? Utf-8? Q? Z = CC = 87o = CC = 81 = C5 = 82w = 2Ertf? =", Which after applying MimeUtility.decodeText is: "ZÃÃÃÃÃÃÅÅÅÇÇ .rtf ". Clearly not the original :).
For comparison, MimeUtility.encodeText returns:
=?UTF-8?Q?=C5=BB=C3=B3=C5=82w.rtf?=
Unlike:
=?utf-8?Q?Z=CC=87o=CC=81=C5=82w=2Ertf?=
outgoing from email.
According to my research, the letter “Ż” can be encoded in two ways: either as a single letter, or as “Z” + above a dot. MimeUtility.encodeText uses the first, Mail.app last.
However, I want to be able to decode both. Is there a way to decode the file name when sending from Mail.app using JavaMail? Or maybe there is another library?
Thanks! Adam
adamw
source share