Hi,

With the default implementation of file upload in Struts,
the data is already written to a temporary file.  Using
the FormFile.getInputStream() method, you can read data
from the stream for the temporary file and write it
to wherever you need to to make it an attachment.

public class EmailAction extends Action {

        public ActionForward perform(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws IOException, ServletException {

        FormFile uploadedFile = form.getSomeFileElement();
        InputStream stream = uploadedFile.getInputStream();
        
        //do things with input stream
    }

-----Original Message-----
From: Griffith Ralph [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 05, 2001 11:02 AM
To: '[EMAIL PROTECTED]'
Subject: FormFile to email attachment


Hello,

Does anyone have any sample code to take the contents of an uploaded file
and add it as an attachment to an email message? Basically, I'm trying to
load the contents of the FormFile object directtly to a mimeBodyPart object
without writing the data to a temporary file first.

Thanks

Reply via email to