Multipart mp = new MimeMultipart(); //set email address(es) ... ... //set message, if any ... ... // create a message part MimeBodyPart mbp = new MimeBodyPart();
// attach the file to the message part FileDataSource fds = new FileDataSource(<full path to file> ); mbp.setDataHandler(new DataHandler(fds)); mbp.setFileName(fds.getName()); //mbp.setDisposition("inline");
// add this part to Multipart mp.addBodyPart(mbp); //more attachements, if any .... .... //send it off using Transport
"rajkumar", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements. Thanks.