Try With this Code
String from = "
[email protected]";
String to = "
[email protected]";
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = "
your host ";
// Create properties, get Session
Properties props = new Properties();
// If using static Transport.send(),
// need to specify which host to send it to
props.put("mail.smtp.host", host);
// To see what is going on behind the scene
props.put("mail.debug", "true");
Session session = Session.getInstance(props);
try {
// Instantiatee a message
Message msg = new MimeMessage(session);
//Set message attributes
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("ONLINE SHOPPING DETAILS ");
msg.setSentDate(new Date());
}
msg.setContent("<h1> Online Shopping Details</h1>", "text/html");
//Send the message
Transport.send(msg);
}
catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
}