Hi guys I've got a very simple mailet that only serves one purpose: saving attachments to the filesystem of the James server. So hopefully this scenario shouldn't be too obscure or difficult to fix.
Using the mailet code below, my files (gif images) get saved to file. But then when I try to open them in IE, I just get the little red cross symbol indicating a corrupt image. When I compare the original file with the transmitted file in Ultraedit I notice that the difference between the two is that there are several ASCII '?' characters littered around the file (HEX code 3F). Also worth pointing out that the images are base64 encoded, and seem to be decoded behind the scenes by JavaMail. Could it be something to do with the automatic decoding of the file? Could somebody take a look at my code and tell me if I'm doing something wrong please. Anyone seen anything simliar to this before? Cheers Nick public void service(Mail mail){ try{ Multipart multipart = (Multipart) mail.getMessage().getContent(); for (int i=0, n=multipart.getCount(); i<n; i++) { Part part = multipart.getBodyPart(i); if ((part.getDisposition() != null) && ((disposition.equals(Part.ATTACHMENT) || (disposition.equals(Part.INLINE)))) && part.isMimeType("image/*")) { MimePartDataSource ds = new MimePartDataSource((MimePart)part); saveFile(part.getFileName(), ds.getInputStream()); } } } catch(MessagingException me){ me.printStackTrace(); } catch(IOException ie){ ie.printStackTrace(); } } private void saveFile(String filename, InputStream is){ try{ File file = new File(filename); FileWriter out = new FileWriter(file); int c; while ((c = is.read()) != -1){ out.write(c); } is.close(); out.close(); } catch(IOException ie){ ie.printStackTrace(); } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>