Send Email With Attachment in Java
public boolean sendEmailWithAttachment() { // create some properties and get the default Session Properties props = System.getProperties(); props.put("mail.smtp.host", "smtp host address"); props.put("mail.smtp.port", "25"); Session session = Session.getInstance(props, new MailAuthenticator()); try { // create a message MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress address = new InternetAddress(to); ...