title: JavaMail requires an InputStreamSource that creates a fresh stream for every call
body: <p>I'm trying to send an attachment using JavaMail via Spring 2.5's MailSender, but I keep getting this error:</p>
  
  <pre><code>Passed-in Resource contains an open stream: invalid argument.
  JavaMail requires an InputStreamSource that creates a fresh stream for every call.
  </code></pre>
  
  <p>I am using an <code>InputStreamResource</code> :</p>
  
  <pre><code>InputStream crofileInputStream = emailDraft.getAttachmentCroFile().getInputStream();
  InputStream nacfileInputStream = emailDraft.getAttachmentNacFile().getInputStream();
  InputStream sourcefileInputStream = emailDraft.getAttachmentSourceFile().getInputStream();
  
  InputStreamSource[] attachments = {new InputStreamResource(crofileInputStream),new InputStreamResource(nacfileInputStream),new InputStreamResource(sourcefileInputStream)};
  
  sentEmailLog = mailSenderService.sendMIMEMessage(emailDraft, attachmentFileNames, attachments);
  </code></pre>
  
  <p>this last instruction calls 
  <code>MimeMessageHelper.addAttachment(fileName,attachments[i])</code> for each attachment.</p>
  
  <p>Please how could i solve this issue ?</p>
  
  <p>Thanks for you help.</p>