My need is I want to use any kind of loop in setContent()
but as it is a method, I am not allowed to do this. So do you have any alternate method for doing this?
Look into my code below
String to = ""; //change accordingly
//Get the session object
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session sessions = Session.getDefaultInstance(props,new javax.mail.Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("", ""); //change accordingly
}
});
MimeMessage message = new MimeMessage(sessions);
message.setFrom(new InternetAddress("")); //change accordingly
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("sai");
message.setContent("Here we can pass html format including css","text/html");
Transport.send(message);
Can anyone please tell me that how can I pass dynamic content in message.setContent()