我的需要是我想在setContent()
中使用任何类型的循环,但由于它是一种方法,我不允许这样做。那么你有没有其他方法来做到这一点?
查看下面的代码
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);
任何人都可以告诉我如何在message.setContent()
答案 0 :(得分:0)