use of com.sendgrid.Content in project teammates by TEAMMATES.
the class SendgridService method parseToEmail.
/**
* {@inheritDoc}
*/
@Override
public Mail parseToEmail(EmailWrapper wrapper) {
Mail email = new Mail();
Email sender;
if (wrapper.getSenderName() == null || wrapper.getSenderName().isEmpty()) {
sender = new Email(wrapper.getSenderEmail());
} else {
sender = new Email(wrapper.getSenderEmail(), wrapper.getSenderName());
}
email.setFrom(sender);
email.setReplyTo(new Email(wrapper.getReplyTo()));
Personalization personalization = new Personalization();
personalization.addTo(new Email(wrapper.getRecipient()));
if (wrapper.getBcc() != null && !wrapper.getBcc().isEmpty()) {
personalization.addBcc(new Email(wrapper.getBcc()));
}
email.addPersonalization(personalization);
email.setSubject(wrapper.getSubject());
email.addContent(new Content("text/plain", Jsoup.parse(wrapper.getContent()).text()));
email.addContent(new Content("text/html", wrapper.getContent()));
return email;
}
Aggregations