use of org.simplejavamail.api.email.Email in project Novel-Grabber by Flameish.
the class EmailNotification method sendAttachment.
/**
* Sends an Email with chapter names/links and created EPUB of novel as attachment.
*/
public void sendAttachment(Novel novel) {
StringBuilder links = new StringBuilder();
for (int i = novel.firstChapter - 1; i < novel.lastChapter; i++) {
links.append("<a href=\"" + novel.chapterList.get(i).chapterURL + "\">" + novel.chapterList.get(i).name + "</a><br>");
}
File epub = new File(novel.saveLocation + "/" + novel.filename);
Email email = EmailBuilder.startingBlank().to(config.getInstance().getReceiverEmail()).from(config.getInstance().getReceiverEmail()).withSubject("[Novel-Grabber]" + novel.metadata.getTitle() + " - Update").withHTMLText(links.toString()).withAttachment(epub.getName(), new FileDataSource(epub)).buildEmail();
mailer.sendMail(email);
GrabberUtils.info("Email send with attachment.");
}
use of org.simplejavamail.api.email.Email in project dew by gudaoxuri.
the class MAILChannel method innerSend.
@Override
public Resp<String> innerSend(String content, String title, Set<String> receivers) throws Exception {
Email email = EmailBuilder.startingBlank().from(emailFrom).toMultiple(receivers).withSubject(title).withPlainText(content).buildEmail();
mailSender.sendMail(email);
return Resp.success("");
}
use of org.simplejavamail.api.email.Email in project backend by CatalogueOfLife.
the class JobExecutor method sendErrorMail.
private void sendErrorMail(BackgroundJob job) {
if (mailer != null && onErrorTo != null && onErrorFrom != null) {
StringWriter sw = new StringWriter();
sw.write(job.getClass().getSimpleName() + " job " + job.getKey());
sw.write(" has failed with an exception");
if (job.getError() != null) {
sw.write(" " + job.getError().getClass().getSimpleName() + ":\n\n");
PrintWriter pw = new PrintWriter(sw);
job.getError().printStackTrace(pw);
} else {
sw.write(".\n");
}
Email mail = EmailBuilder.startingBlank().to(onErrorTo).from(onErrorFrom).withSubject(String.format("COL job %s %s failed", job.getClass().getSimpleName(), job.getKey())).withPlainText(sw.toString()).buildEmail();
mailer.sendMail(mail, true);
}
}
use of org.simplejavamail.api.email.Email in project nzyme by lennartkoopmann.
the class EmailCallback method call.
@Override
public void call(Alert alert) {
LOG.info("Sending alert email.");
try {
Email email = EmailBuilder.startingBlank().to(configuration.recipients()).from(configuration.from()).withSubject(configuration.subjectPrefix() + " " + buildSubject(alert)).withPlainText(buildPlainTextBody(alert)).withHTMLText(buildHTMLTextBody(alert)).withEmbeddedImage("nzyme_logo", loadLogoFile(), "image/png").buildEmail();
mailer.sendMail(email);
} catch (Exception e) {
LOG.error("Could not send Email.", e);
}
}
use of org.simplejavamail.api.email.Email in project spring-zerocell by nndi-oss.
the class ExcelToEmailController method sendEmailToCustomer.
private void sendEmailToCustomer(Customer customer) {
Email email = EmailBuilder.startingBlank().from("noreply@nndi-tech.com").to(customer.getFullName(), customer.getEmail()).withSubject("Spring Zerocell Newsletter").withPlainText(String.format("Hello %s, \nPlease view this email in a modern email client!", customer.getFullName())).buildEmail();
Mailer mailer = MailerBuilder.withDebugLogging(true).withSessionTimeout(10 * 1000).async().buildMailer();
mailer.sendMail(email);
}
Aggregations