tags:

views:

18

answers:

1

I am trying to download an attachment from GMAIL using the java mail API, this the the code snippet

System.setProperty("mail.mime.base64.ignoreerrors", "true")

if ( mp.getBodyPart(i).disposition == "ATTACHMENT" ) {
    def OutputStream out
    try {
        out = new BufferedOutputStream(newFileOutputStream("/_1test.pdf"));       
        out.write(IOUtils.toByteArray(mp.getBodyPart(i).getInputStream()));
    } finally {
        if (out != null) out.close();
    }
 }

the code runs fine and there are no exceptions, but the file that is created cannot be opened in acrobat

A: 

Found the problem, needed to set the partialfetch flag to false...

props.put("mail.imap.partialfetch", "false");
Aaron Saunders