commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Petr Osipov (JIRA)" <>
Subject [jira] [Created] (EMAIL-155) Not Able To Parse Attachments
Date Wed, 24 Jun 2015 12:51:04 GMT
Petr Osipov created EMAIL-155:

             Summary: Not Able To Parse Attachments
                 Key: EMAIL-155
             Project: Commons Email
          Issue Type: Bug
         Environment: org.apache.commons:commons-email:1.4
            Reporter: Petr Osipov
            Priority: Critical

h4. Scenario
# Sent an email from Microsoft Web UI,
# When code tries to parse
    public DataSource getAttachment(String username, MimeMessage mimeMessage) throws Exception
        MimeMessageParser messageParser = new MimeMessageParser(mimeMessage);
        // further code
An exception is thrown
java.lang.ClassCastException: javax.mail.util.SharedByteArrayInputStream cannot be cast to
	at org.apache.commons.mail.util.MimeMessageParser.parse(
	at org.apache.commons.mail.util.MimeMessageParser.parse(

Probably int the wild casting to javax.mail.Multipart in MimeMessageParser is a too brave
                if (isMimeType(part, "multipart/*"))
                    this.isMultiPart = true;
                    final Multipart mp = (Multipart) part.getContent();
                    final int count = mp.getCount();

                    // iterate over all MimeBodyPart

                    for (int i = 0; i < count; i++)
                        parse(mp, (MimeBodyPart) mp.getBodyPart(i));

This message was sent by Atlassian JIRA

View raw message