use of org.broadleafcommerce.common.email.domain.EmailTarget in project BroadleafCommerce by BroadleafCommerce.
the class EmailServiceImpl method sendTemplateEmail.
public boolean sendTemplateEmail(String emailAddress, EmailInfo emailInfo, Map<String, Object> props) {
if (!(emailInfo instanceof NullEmailInfo)) {
EmailTarget emailTarget = emailReportingDao.createTarget();
emailTarget.setEmailAddress(emailAddress);
return sendTemplateEmail(emailTarget, emailInfo, props);
} else {
return true;
}
}
use of org.broadleafcommerce.common.email.domain.EmailTarget in project BroadleafCommerce by BroadleafCommerce.
the class MessageCreator method buildMimeMessagePreparator.
public MimeMessagePreparator buildMimeMessagePreparator(final Map<String, Object> props) {
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws Exception {
EmailTarget emailUser = (EmailTarget) props.get(EmailPropertyType.USER.getType());
EmailInfo info = (EmailInfo) props.get(EmailPropertyType.INFO.getType());
boolean isMultipart = CollectionUtils.isNotEmpty(info.getAttachments());
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, info.getEncoding());
message.setTo(emailUser.getEmailAddress());
message.setFrom(info.getFromAddress());
message.setSubject(info.getSubject());
if (emailUser.getBCCAddresses() != null && emailUser.getBCCAddresses().length > 0) {
message.setBcc(emailUser.getBCCAddresses());
}
if (emailUser.getCCAddresses() != null && emailUser.getCCAddresses().length > 0) {
message.setCc(emailUser.getCCAddresses());
}
String messageBody = info.getMessageBody();
if (messageBody == null) {
messageBody = buildMessageBody(info, props);
}
message.setText(messageBody, true);
for (Attachment attachment : info.getAttachments()) {
ByteArrayDataSource dataSource = new ByteArrayDataSource(attachment.getData(), attachment.getMimeType());
message.addAttachment(attachment.getFilename(), dataSource);
}
}
};
return preparator;
}
Aggregations