Frattak
Frattak

Reputation: 1

How to decode an attachment chunked filename in javamail?

I am trying to figure out how to manage an attachment of a mail that has the filename chunked. I am on java 1.6 with javamail 1.5.1 and my code can manage all kind of mails but when I receive one from a specific adress(i can't talk with those guys) it doesn't import some attachments properly. When I open those atachments(assuming that this one's name is filename without extension.extension) with notepad I find this:

Content-Type: application/octet-stream; 
    name*0="filename without extension"; name*1=.extension
Content-Transfer-Encoding: base64
Content-Disposition: attachment; 
    filename*0="filename without extension"; filename*1=.extension

before the base64 content. I tried to search for similar problems but I have the exact filename but it's splitted and the BodyPart.getFilename() method returns null. I was thinking about taking the whole header and work on that.

Upvotes: 0

Views: 1297

Answers (1)

Erwin Bolwidt
Erwin Bolwidt

Reputation: 31279

This should be supported by your version of Javamail.

System.setProperty("mail.mime.decodeparameters", "true");

For more info, search for "RFC 2231" on the package documentation of javax.mail.internet:

https://docs.oracle.com/javaee/6/api/javax/mail/internet/package-summary.html

Upvotes: 1

Related Questions