commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sid (JIRA)" <>
Subject [jira] [Created] (EMAIL-180) Unable to read filename with 28+ characters
Date Mon, 16 Jul 2018 20:18:00 GMT
sid  created EMAIL-180:

             Summary: Unable to read filename with 28+ characters  
                 Key: EMAIL-180
             Project: Commons Email
          Issue Type: Bug
            Reporter: sid 


I am using version 1.5 and trying to parse outlook email,

I have noticed  bodyPart .getFileName() returns value *null* ( where bodyPart = (Multipart)
mimeMessage.getContent().getBodyPart()), with headers such as below(generated within outlook
email) for an example -

Content-Type: application/pdf;
{color:#FF0000}name="ABCDEFG test case without contract id #1.pdf"{color}
Content-Description: ABCDEFG test case without contract id #1.pdf
Content-Disposition: attachment;
filename="ABCDEFG test case without contract id #1.pdf"; size=484417;
creation-date="Sun, 15 Jul 2018 15:12:47 GMT";
modification-date="Sun, 15 Jul 2018 15:13:15 GMT"
Content-Transfer-Encoding: base64

my primary observation is - due to character limitation according to RFC, the headers gets
broken and gets displaced on next separate line - which parser is unable to parse.

However, for now - I am using this custom method to handle such issues.

public static String parseDescriptionFileHeader(Enumeration headerEnumeration) {
 String fileName = null;
 try {
 while (headerEnumeration.hasMoreElements()) {
 Header header = (Header) headerEnumeration.nextElement();
 String name = header.getName();
 Pattern p = Pattern.compile("\"([^\"]*)\"");
 Matcher m = p.matcher(name);
 while (m.find()) {
 fileName =;
 return fileName;
 } catch (Exception e) {
system.out.println("Unable to retrieve attachement header");
 return fileName;

Let me know, if there is any standard solution to the above issue, Thank you.


This message was sent by Atlassian JIRA

View raw message