send attachment
Hi everybody,
i am devloping browser based app to send&retrive mail with help of mail api(like yahoo).
i am getting problem in sending attachment means with help of html(file tag)&java script how will be i able to send attachment from client to remote server.
plz help.
[302 byte] By [
raj_siraja] at [2007-11-26 17:38:52]

# 1
You can refer to the FAQ:
http://java.sun.com/products/javamail/FAQ.html#attach
Also the sample code will look like the following:
// Define message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail Attachment");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("Pardon Ideas");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send(message);