Examples of HtmlEmail


Examples of org.apache.commons.mail.HtmlEmail

                System.out.println(needAuth);
            }

            Email email;
            if (html) {
                email = new HtmlEmail();
            } else {
                email = new SimpleEmail();
            }
            email.setHostName(host);
            if (needAuth.equalsIgnoreCase("true")) {
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

            if (infoMap.get(ATTACHMENTS) == null) {
//                if (StringUtils.isEmpty(bodyHtml)) {
//                    email = new SimpleEmail();
//                    email.setMsg(bodyText);
//                } else {
                    HtmlEmail htmlEmail = new HtmlEmail();
                    htmlEmail.setHtmlMsg(bodyHtml);
//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }

            } else {
//                if (StringUtils.isEmpty(bodyHtml)) {
//                    email = new MultiPartEmail();
//                    email.setMsg(bodyText);
//                } else {
                    HtmlEmail htmlEmail = new HtmlEmail();
                    htmlEmail.setHtmlMsg(bodyHtml);
//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

            if (infoMap.get(ATTACHMENTS) == null) {
//                if (StringUtils.isEmpty(bodyHtml)) {
//                    email = new SimpleEmail();
//                    email.setMsg(bodyText);
//                } else {
                    HtmlEmail htmlEmail = new HtmlEmail();
                    htmlEmail.setHtmlMsg(bodyHtml);
//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }

            } else {
//                if (StringUtils.isEmpty(bodyHtml)) {
//                    email = new MultiPartEmail();
//                    email.setMsg(bodyText);
//                } else {
                    HtmlEmail htmlEmail = new HtmlEmail();
                    htmlEmail.setHtmlMsg(bodyHtml);
//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

                return false;
            }
            if (subject == null) {
                return false;
            }
            HtmlEmail mail = new HtmlEmail();
            mail.setHostName(hostname);
            if (port == -1) {
                port = 25;
            }

            if(username != null && password != null)
            mail.setAuthentication(username, password);

            mail.setSmtpPort(port);
            mail.setCharset(HtmlEmail.ISO_8859_1);
            for (String t : tos) {
                try {
                    mail.addTo(t, t);
                } catch (EmailException ex) {
                    System.err.print(ex);
                    return false;
                }
            }
            mail.setFrom(from);
            mail.setSubject(subject);
            if (html == null) {
                html = text;
            }

            mail.setHtmlMsg(html);
            mail.setTextMsg(text);
            mail.send();
            return true;
        } catch (EmailException ex) {
            System.err.print(ex);
            return false;
        }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    @Test
    public void testParseCreatedHtmlEmailWithNoContent() throws Exception
    {
        final Session session = Session.getDefaultInstance(new Properties());

        final HtmlEmail email = new HtmlEmail();

        email.setMailSession(session);

        email.setFrom("test_from@apache.org");
        email.setSubject("Test Subject");
        email.addTo("test_to@apache.org");

        email.buildMimeMessage();
        final MimeMessage msg = email.getMimeMessage();

        final MimeMessageParser mimeMessageParser = new MimeMessageParser(msg);
        mimeMessageParser.parse();

        assertEquals("Test Subject", mimeMessageParser.getSubject());
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    @Test
    public void testParseCreatedHtmlEmailWithTextContent() throws Exception
    {
        final Session session = Session.getDefaultInstance(new Properties());

        final HtmlEmail email = new HtmlEmail();

        email.setMailSession(session);

        email.setFrom("test_from@apache.org");
        email.setSubject("Test Subject");
        email.addTo("test_to@apache.org");
        email.setTextMsg("My test message");

        email.buildMimeMessage();
        final MimeMessage msg = email.getMimeMessage();

        final MimeMessageParser mimeMessageParser = new MimeMessageParser(msg);
        mimeMessageParser.parse();

        assertEquals("Test Subject", mimeMessageParser.getSubject());
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    @Test
    public void testParseCreatedHtmlEmailWithMixedContent() throws Exception
    {
        final Session session = Session.getDefaultInstance(new Properties());

        final HtmlEmail email = new HtmlEmail();

        email.setMailSession(session);

        email.setFrom("test_from@apache.org");
        email.setSubject("Test Subject");
        email.addTo("test_to@apache.org");
        email.setTextMsg("My test message");
        email.setHtmlMsg("<p>My HTML message</p>");

        email.buildMimeMessage();
        final MimeMessage msg = email.getMimeMessage();

        final MimeMessageParser mimeMessageParser = new MimeMessageParser(msg);
        mimeMessageParser.parse();

        assertEquals("Test Subject", mimeMessageParser.getSubject());
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    private void createAndSendAlertEmail(String body)
    {
        try {
            log.info(String.format("Sending alert email to [%s]: %s", config.getRecipients(), body));

            HtmlEmail email = new HtmlEmail();

            email.setTextMsg(body);
            email.setFrom("esper-is-awesome@example.com");
            email.setTo(Arrays.asList(new InternetAddress(config.getRecipients())));
            email.setHostName(config.getHost());
            email.setSmtpPort(config.getPort());
            email.send();
        }
        catch (Exception ex) {
            log.warn("Could not create or send email", ex);
        }
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

      throw new ProcessEngineException("'html' or 'text' is required to be defined when using the mail activity");
    }
  }

  protected HtmlEmail createHtmlEmail(String text, String html) {
    HtmlEmail email = new HtmlEmail();
    try {
      email.setHtmlMsg(html);
      if (text != null) { // for email clients that don't support html
        email.setTextMsg(text);
      }
      return email;
    } catch (EmailException e) {
      throw new ProcessEngineException("Could not create HTML email", e);
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

            if (infoMap.get(ATTACHMENTS) == null) {
//                if (StringUtils.isEmpty(bodyHtml)) {
//                    email = new SimpleEmail();
//                    email.setMsg(bodyText);
//                } else {
                    HtmlEmail htmlEmail = new HtmlEmail();
                    htmlEmail.setHtmlMsg(bodyHtml);
//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }

            } else {
//                if (StringUtils.isEmpty(bodyHtml)) {
//                    email = new MultiPartEmail();
//                    email.setMsg(bodyText);
//                } else {
                    HtmlEmail htmlEmail = new HtmlEmail();
                    htmlEmail.setHtmlMsg(bodyHtml);
//                    if (!StringUtils.isEmpty(bodyText)) {
//                        htmlEmail.setTextMsg(bodyText);
//                    }
                    email = htmlEmail;
//                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.