List of usage examples for org.apache.commons.mail HtmlEmail HtmlEmail
HtmlEmail
From source file:uap.workflow.engine.bpmn.behavior.MailActivityBehavior.java
protected HtmlEmail createHtmlEmail(String text, String html) { HtmlEmail email = new HtmlEmail(); try {/*from ww w . ja va 2 s.c o m*/ email.setHtmlMsg(html); if (text != null) { // for email clients that don't support html email.setTextMsg(text); } return email; } catch (EmailException e) { throw new WorkflowException("Could not create HTML email", e); } }
From source file:util.Log.java
public static void relatarExceptionEmail(String className, String exception, String logPath) { /*/*from www . j a v a 2 s .c o m*/ * Para compreender melhor acesse esse site: * http://www.botecodigital.info/java/enviando-e-mail-em-java-com-api- * commons-email-da-apache/ */ HtmlEmail email = new HtmlEmail(); email.setSSLOnConnect(true); email.setHostName("smtp.gmail.com"); email.setSslSmtpPort("465"); email.setAuthenticator(new DefaultAuthenticator("jjsoftwares10@gmail.com", "jean1420")); try { email.setFrom("jjsoftwares10@gmail.com", "Software da clinica"); email.setSubject("Exceo ocorrida no app da clinica"); StringBuilder msg = new StringBuilder(); msg.append("<h1 style=\"text-align: center;\">Excecao Ocorrida</h1>"); msg.append("<p><strong>Na Classe: " + className + " </strong></p>"); msg.append("<p><strong>Data e Horario do ocorrido: " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:s")) + "</strong></p>"); msg.append("<h2 style=\"text-align: center;\"><strong>Excecao</strong></h2>"); msg.append("<p><span style=\"color: #ff0000;\">" + exception + "</span></p>"); msg.append("<p><strong>Segue anexo com detalhes</strong></p>"); /*Enviando o anexo com detalhes da exceo*/ File arqLog = new File(logPath); if (arqLog.exists()) { EmailAttachment anexo = new EmailAttachment(); anexo.setPath(logPath); anexo.setDisposition(EmailAttachment.ATTACHMENT); anexo.setName(arqLog.getName()); email.attach(anexo); } /*enviando*/ email.setHtmlMsg(msg.toString()); email.addTo("jeandersonfju@gmail.com"); email.addTo("jeff-assis@hotmail.com"); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
From source file:velo.tools.EdmEmailSender.java
License:asdf
public Email factoryEmail(String subject, String body) throws EmailException { HtmlEmail he = new HtmlEmail(); he.setSubject(subject);/* ww w . j av a2 s. com*/ he.setHtmlMsg(body); he.setCharset("UTF-8"); he.setHostName(getHostName()); he.setFrom(fromAddress); return he; }
From source file:velo.tools.EmailSender.java
public void addHtmlEmail(String fromAddress, Collection<String> recipient, String subject, String body) throws EmailException { HtmlEmail email = new HtmlEmail(); email.setHostName(getHostName());/*from w ww. java 2s . com*/ //email.addTo("jdoe@somewhere.org", "John Doe"); //email.addTo(recipient,recipient); email.setFrom(fromAddress, fromAddress); email.setSubject(subject); email.setHtmlMsg(body); for (String currRec : recipient) { email.addTo(currRec); } email.setCharset("UTF-8"); log.debug("Adding a new message with subject '" + subject + "', from: '" + fromAddress + "', to: '" + recipient + "' to the queue..."); log.debug("Email server parameters - SMTP host: " + getHostName()); emails.add(email); }