public static Boolean sendHtmlMailWithAttachment(List<String> toAddress,
String hostName, Integer smtpPort, String from, String username,
String password, String subject, String htmlMessage,
List<EmailAttachment> attachment) {
// Create data information to compose the mail
HtmlEmail email = new HtmlEmail();
configureBasics(hostName, smtpPort, from, username, password, email, false);
for (EmailAttachment attach : attachment) {
try {
email.attach(attach);
} catch (EmailException e) {
e.printStackTrace();
}
}
email.setSubject(subject);
try {
email.setHtmlMsg(htmlMessage);
} catch (EmailException e1) {
e1.printStackTrace();
return false;
}
email.setSSL(true);
// send to all mails extracted from settings
for (String add : toAddress) {
try {
email.addBcc(add);
} catch (EmailException e) {
e.printStackTrace();
return false;
}
}