Have alook at this
try
{
String host="192.168.1.83";
String to=request.getParameter("to");
String from=request.getParameter("from");
String sub=request.getParameter("sub");
String matter=request.getParameter("matter");
String filename=request.getParameter("F1");
boolean sessionDebug=false;
Properties props=System.getProperties();
props.put("mail.host",host);
props.put("mail.transport.protocol","smtp");
Session mailSession=Session.getDefaultInstance(props,null);
mailSession.setDebug(sessionDebug);
Message msg=new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address={new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO,address);
msg.setSubject(sub);
msg.setSentDate(new Date());
msg.setText(matter);
BodyPart bp=new MimeBodyPart();
bp.setText(matter);
Multipart multipart=new MimeMultipart();
multipart.addBodyPart(bp);
BodyPart msgpart=new MimeBodyPart();
DataSource source=new FileDataSource(filename);
msgpart.setDataHandler(new DataHandler(source));
msgpart.setFileName(filename);
multipart.addBodyPart(msgpart);
msg.setContent(multipart);
Transport.send(msg);
out.println("Mail was successfully sent to"+to);
out.println("from"+from);
out.println("using host"+".");
}
catch(Exception e)
{
}