views:

332

answers:

1

I need to make a simple page in JSP. I've never worked in JSP before ever.

I have a form that has two fields: one is a file upload field and the other is a textbox. The user enters one email address in the field and uploads a file and upon submission. I should be able to email the attachment to the email address entered.

I need a quick code snippet that does this.

+4  A: 

try to see this code, might need some debugging though :)

or this one from here (through the JavaMail API):

  SmtpSender smtp=SmtpSender.getInstance();
   MailToBeSent send=new MailToBeSent();
   send.setSubject("Hello");
   send.setFromAddress("[email protected]","Someone");
   send.addToAddress("[email protected]","Anotherone");
   send.setBody("Hello, test with the file attachment!");
   byte[] bin=.....
   send.attacheFile(bin,"photo.jpg","image/jpeg");
   smtp.sendMail(send);
pageman
Thanks man :) that saved my day
Ali
@Ali would appreciate an upvote hehehe :)
pageman