i want to send below mentioned results to email and want to receive them in email carefully. therefore i decide to use html code, but no result.
Code:
public static void sendresult ( ShowResultModel showuserresulttable) {
final String username = *****
final String password = ******;
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("mekteb48@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("iismayilov028@gmail.com"));
message.setSubject("Exammer result :" + showuserresulttable.getUsername() );
DecimalFormat formatter = new DecimalFormat("#0.00");
String MESSAGE = " ";
double resultpercent = showuserresulttable.getScore() /(double) showuserresulttable.getTotalanswer()*100;
MESSAGE+="<b>Username:</b> " + showuserresulttable.getUsername() + "<br><hr>";
MESSAGE+="<b>Subject</b>" + showuserresulttable.getSubject() + "<br><hr>";
MESSAGE+="<b>Variant :</b>" + showuserresulttable.getVariant() + "<br><hr>";
MESSAGE+="<b>Score of result:</b>" + showuserresulttable.getScore() + "<br><hr>";
MESSAGE+="<b>Total question :</b>" + showuserresulttable.getTotalanswer()+ "<br><hr>";
MESSAGE+="<b> Score percent:</b>" + resultpercent + "<br><hr>";
MESSAGE+="<b>Spendtime:</b>" + showuserresulttable.getSpendtime() + "second" + "<br><hr>";
MESSAGE+="<b>Examdate:</b>" + showuserresulttable.getExamdate() ;
message.setText(MESSAGE);
Transport.send(message);
System.out.println("Mail gonderildi!");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}