Examples of HtmlEmail


Examples of org.apache.commons.mail.HtmlEmail

        notifiers.Welcome.welcome3();
        renderText("OK4");
    }

    public static void mail5() throws EmailException {
        HtmlEmail email = new HtmlEmail();
        email.setHtmlMsg("<html><body><h1>A Title</h1></body></html>");
        email.setTextMsg("alternative message");
        EmailAttachment attachment = new EmailAttachment();
        attachment.setDescription("An image");
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setPath(Yalp.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond2.png");
        EmailAttachment attachment2 = new EmailAttachment();
        attachment2.setName("fond3.jpg");
        attachment2.setPath(Yalp.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond3.jpg");
        email.attach(attachment);
        email.attach(attachment2);
        email.setFrom("test@localhost");
        email.addTo("test@localhost");
        email.setSubject("test attachments");
        Mail.send(email);
        renderText("OK5");
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", this.localization.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    email.setCharset("utf-8");
   
    try {
     
      addEmbeddables(email);
      addAttachments(email);
     
      email.addTo(toMail, name);
      email.setSubject(this.localization.getMessage(this.templateName, nameParameters));
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", bundle.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    email.setCharset("utf-8");
    try {
      addEmbeddables(email);
      addAttachments(email);
      email.addTo(toMail, name);
      boolean hasNoSubjectDefined = this.bundle.getMessage(templateName,
          nameParameters).equals("???" + templateName + "???");
      if (hasNoSubjectDefined) {
        throw new IllegalArgumentException(
            "Subject not defined for email template : " + templateName);
      } else {
        email.setSubject(this.bundle.getMessage(this.templateName, nameParameters));
      }
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

public class EmailBuilder {
 
  private final HtmlEmail email;
 
  public EmailBuilder() throws EmailException {
    email = new HtmlEmail();
    email.setCharset(EmailConstants.ISO_8859_1);
    email.setFrom("indica@sorricred.com.br", "Sorricred");
  }
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

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", this.localization.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    try {
      email.addTo(toMail, name);
      email.setSubject(this.localization.getMessage(this.templateName, nameParameters));
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

   */
  public void sendHTML(String from, String to, String cc, String bcc, String bounceAddress, String replyTo, String subject, String content, String encoding) throws SystemException
  {
    try
    {
      HtmlEmail email = new HtmlEmail();
        String mailServer = CmsPropertyHandler.getMailSmtpHost();
        String mailPort = CmsPropertyHandler.getMailSmtpPort();
        String systemEmailSender = CmsPropertyHandler.getSystemEmailSender();
       
        email.setHostName(mailServer);
        if(mailPort != null && !mailPort.equals(""))
          email.setSmtpPort(Integer.parseInt(mailPort));
       
        boolean needsAuthentication = false;
        try
        {
        needsAuthentication = new Boolean(CmsPropertyHandler.getMailSmtpAuth()).booleanValue();
        }
        catch (Exception ex)
        {
        needsAuthentication = false;
        }
       
        if (needsAuthentication)
        {
        final String userName = CmsPropertyHandler.getMailSmtpUser();
        final String password = CmsPropertyHandler.getMailSmtpPassword();
       
        email.setAuthentication(userName, password);
      }
       
        email.setBounceAddress(systemEmailSender);
        email.setCharset(encoding);
      
        if(logger.isInfoEnabled())
        {
          logger.info("systemEmailSender:" + systemEmailSender);
          logger.info("to:" + to);
          logger.info("from:" + from);
          logger.info("mailServer:" + mailServer);
          logger.info("mailPort:" + mailPort);
          logger.info("cc:" + cc);
          logger.info("bcc:" + bcc);
          logger.info("replyTo:" + replyTo);
          logger.info("subject:" + subject);
        }
       
        if(to.indexOf(";") > -1)
        {
          cc = to;
          to = from;
        }
       
        String limitString = CmsPropertyHandler.getEmailRecipientLimit();
        if(limitString != null && !limitString.equals("-1"))
        {
          try
          {
            Integer limit = new Integer(limitString);
            int count = 0;
            if(cc != null)
              count = count + cc.split(";").length;
            if(bcc != null)
              count = count + bcc.split(";").length;
           
            logger.info("limit: " + limit + ", count: " + count);
            if(count > limit)
              throw new Exception("You are not allowed to send mail to more than " + limit + " recipients at a time. This is specified in app settings.");
          }
          catch (NumberFormatException e)
          {
            logger.error("Exception validating number of recipients in mailservice:" + e.getMessage(), e);
        }
        }
       
        email.addTo(to, to);
        email.setFrom(from, from);
        if(cc != null)
          email.setCc(createInternetAddressesList(cc));
        if(bcc != null)
          email.setBcc(createInternetAddressesList(bcc));
        if(replyTo != null)
          email.setReplyTo(createInternetAddressesList(replyTo));
       
        email.setSubject(subject);
       
        email.setHtmlMsg(content);
       
        //email.setTextMsg(Jsoup.parse(content).text());
 
        email.send();

        logger.info("Email sent!");
    }
      catch (Exception e)
      {
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

      throw new ActivitiException("'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 ActivitiException("Could not create HTML email", e);
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", this.localization.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    try {
     
      addEmbeddables(email);
      addAttachments(email);
     
      email.addTo(toMail, name);
      email.setSubject(this.localization.getMessage(this.templateName, nameParameters));
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
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.