10 Jan 11
Using Java Mail API
In order to have the ability of sending email from your java program, you would need Java Mail API. It could be obtained here.
The following code illustrate how to use it. (Comment will guide you thru)
// Obtain the system property and set inside the SMTP server
Properties props = System.getProperties();
props.put("mail.smtp.host", "your isp smtp");
// Obtain the mail session
Session session = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(session);
// Set the address for sender
message.setFrom(new InternetAddress("sender mail address"));
// Set the address for recipient
message.addRecipient(Message.RecipientType.TO, new InternetAddress("recipient mail address"));
// Set the Subject of the mail
message.setSubject("Subject");
// Set the message content of the mail
message.setContent("Message Body", "text/plain");
// Send the mail
Transport.send(message);