Hi try that :
//Message MimeMessage mensaje = new MimeMessage(session); mensaje.setFrom(new InternetAddress(from)); InternetAddress[] address = {new InternetAddress(TO)};//where TO is an email address mensaje.setRecipients(Message.RecipientType.TO, address); mensaje.setSubject(subject); mensaje.setSentDate(new Date()); if (attach.length()!=0) { // Text MimeBodyPart text = new MimeBodyPart(); Text.setText(Body); MimeBodyPart Bin = new MimeBodyPart(); DataSource mySource = new FileDataSource (attach); //Binary Bin.setDataHandler(new DataHandler(mySource)); Bin.setFileName(attach); // Join and Seending MimeMultipart multiple = new MimeMultipart(); multiple.addBodyPart(Text); multiple.addBodyPart(Bin); mensaje.setContent(multiple); -- Alexandre Jaquet ----- Original Message ----- From: "Eva Sager" <[EMAIL PROTECTED]> To: "Struts Users Mailing List (E-mail)" <[EMAIL PROTECTED]> Sent: Wednesday, March 05, 2003 3:21 PM Subject: Problems with FormFile.getInputStream() > I am using a file tag to upload a file and that seems to be working fine. I > then want to email that file as an attachment and that is where I start to > run into trouble. I am then trying to make a MimeBodyPart with the > InputStream of the FormFile and the resulting file isn't complete. It is as > if the first part of the file is lost. I have a Vector of FormFiles that I > am working with: > > MimeBodyPart[] attachments = new > MimeBodyPart[form.getAttachments().size()]; > for(int i=0;i<form.getAttachments().size();i++) > { > FormFile file = > (FormFile)form.getAttachments().elementAt(i); > > //printing out the size and first charcter of the io > stream from the FormFile > log.debug("size of formfile="+file.getFileSize()); > log.debug("start > formfile="+file.getInputStream().read()); > > attachments[i] = new MimeBodyPart(file.getInputStream()); > attachments[i].setFileName(file.getFileName()); > attachments[i].setDisposition(MimeBodyPart.ATTACHMENT); > > //printing out the size and first charcter of the io > stream from the BodyPart > log.debug("size of body part="+attachments[i].getSize()); > log.debug("start of body > part="+attachments[i].getInputStream().read()); > > } > > The resulting MimeBodyPart appears to be only a portion of the original > file, and the logging produced supports this. > > size of formfile=1914 > start formfile=84 > size of body part=1717 > start of body part=67 > > I am at a loose at to what I am doing wrong... any assistance would be > appreciated. > > Thanks, > Eva > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]