Search in sources :

Example 1 with Content

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;
}
Also used : Mail(com.sendgrid.Mail) Email(com.sendgrid.Email) Personalization(com.sendgrid.Personalization) Content(com.sendgrid.Content)

Aggregations

Content (com.sendgrid.Content)1 Email (com.sendgrid.Email)1 Mail (com.sendgrid.Mail)1 Personalization (com.sendgrid.Personalization)1