Link to home
Start Free TrialLog in
Avatar of ramoore
ramoore

asked on

JSP, javamail attachments

Hello, I have a jsp page that includes the javamail snippet below. This works fine, but I need to know how to modify this to include one or more attachments. For example, I have the files;
c:\myFile.txt AND c:\myImage.gif that I would like to include. Any help is appreciated!

<%
        Properties props = new Properties();
      props.put("mail.host", "mailsrv");
      Session s = Session.getInstance(props,null);

      MimeMessage message = new MimeMessage(s);

      InternetAddress from = new InternetAddress("myweb@toothbrush.com");
      message.setFrom(from);
      
         InternetAddress[] addresses={
        new InternetAddress("sammy@yourweb.com"),
        new InternetAddress("greg@hisweb.com")};      
 
        message.setRecipients(Message.RecipientType.TO, addresses);
        message.setSubject("MY MAIL TEST);
        message.setText("This is my message");
      
       Transport.send(message);
%>
ASKER CERTIFIED SOLUTION
Avatar of Jaax
Jaax
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ramoore
ramoore

ASKER

Thank you for your response.