sending attatchments....
843830Jul 26 2002 — edited Aug 26 2002hi all,
Im developing a webmail and i've seen on the net about how to send an attatchment in mail..i found this.....
try {
String text="This is the file attachment";
// create a message
Message msg = new MimeMessage(mailsession);
Address fromAddress=new InternetAddress(from);
// set the from
msg.setFrom(fromAddress);
InternetAddress[] address ={new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subj);
MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(text, "text/plain");
File f = new File(filename);
MimeBodyPart attachFilePart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(f);
attachFilePart.setDataHandler(new DataHandler(fds));
attachFilePart.setFileName(fds.getName());
Multipart mp = new MimeMultipart();
mp.addBodyPart(textPart);
mp.addBodyPart(attachFilePart);
msg.setContent(mp);
Transport.send(msg);
out.println("Your attachment has been sent successfully");
}
catch (Exception e)
{
System.out.println(e);
}
....
but this is code tries to send the files from the server wright... so before sending a mail with attatchments...we need to upload the file to the webserver and then send the email with attatchment...so i just want to know is this wright way of sending mails with attatchments...
any inputs on this..
kiran