Examples of HtmlEmail


Examples of org.apache.commons.mail.HtmlEmail

  public void sendMail(EmailDetailsDto emailDto) throws SwingObjectsException{
    MultiPartEmail email=null;
    try {
      if(emailDto.isHtml()) {
        email=new HtmlEmail();
        ((HtmlEmail)email).setHtmlMsg(emailDto.getBody());

      }else {
        email = new MultiPartEmail();
        email.setMsg(emailDto.getBody());
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

   * @param conf ConnectionConfig 邮件服务器连接参数
   * @param mailAddress MailAddress 邮件地址
   * @param mail TextMail 文本内容
   */
  public void sendHtml( ConnectionConfig conf, MailAddress mailAddress, MailContent mail ){   
    HtmlEmail email = new HtmlEmail();     
    fillConfig( email,conf,mailAddress,mail );
   
    try{
      email.send();
    }catch( org.apache.commons.mail.EmailException ee){
      throw new MailException( ee );
    }   
  }
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);
      boolean hasNoSubjectDefined = this.localization.getMessage(templateName,
          nameParameters).equals("???" + templateName + "???");
      if (hasNoSubjectDefined) {
        throw new IllegalArgumentException(
            "Subject not defined for email template : " + templateName);
      } else {
        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

    this.mimeRegistry = mimeRegistry;
    this.root = new EmailContentLocation(this, null, "");
    try
    {

      htmlEmail = new HtmlEmail();
      htmlEmail.setHostName("127.0.0.1");
      htmlEmail.addTo("foo@127.0.0.1", "Dummy To");
      htmlEmail.setFrom("bar@127.0.0.1", "Dummy From");
      htmlEmail.setSubject("Subject");
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    }

    @Override
    public void send(EmailAccount from, Email email) {
        try {
            final HtmlEmail message = new HtmlEmail();
            message.setHostName(smtProperties.getProperty("mail.smtp.host"));
            message.setSmtpPort(Integer.parseInt(smtProperties.getProperty("mail.smtp.port")));
            message.setAuthenticator(new DefaultAuthenticator(
                    from.getEmailAddress(), encrypter.decrypt(from.getPassword())));
            message.setTLS(true);
            message.setFrom(from.getEmailAddress());
            message.setSubject(email.getTitle());
            message.setHtmlMsg(email.getContent());
            message.setMsg(email.getContent());
            message.addTo(email.getContact().getEmail());
            doSend(message);
        } catch (Exception e) {
            throw new RuntimeException("Unable to send mail", e);
        }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

     * @throws EmailException
     */
    public static Boolean sendHtmlMail(List<String> toAddress, String subject,
            String htmlMessage, SettingManager settings) {
        // Create data information to compose the mail
        HtmlEmail email = new HtmlEmail();
        configureBasics(settings, email);

        email.setSubject(subject);
        try {
            email.setHtmlMsg(htmlMessage);
        } catch (EmailException e1) {
            e1.printStackTrace();
            return false;
        }

        // send to all mails extracted from settings
        for (String add : toAddress) {
            try {
                email.addBcc(add);
            } catch (EmailException e) {
                e.printStackTrace();
                return false;
            }
        }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

     */
    public static Boolean sendHtmlMail(List<String> toAddress, String hostName,
            Integer smtpPort, String from, String username, String password,
            String subject, String htmlMessage) {
        // Create data information to compose the mail
        HtmlEmail email = new HtmlEmail();

        configureBasics(hostName, smtpPort, from, username, password, email, false);

        email.setSubject(subject);
        try {
            email.setHtmlMsg(htmlMessage);
        } catch (EmailException e1) {
            e1.printStackTrace();
            return false;
        }
        email.setSSL(true);

        // send to all mails extracted from settings
        for (String add : toAddress) {
            try {
                email.addBcc(add);
            } catch (EmailException e) {
                return false;
            }
        }

View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    public static Boolean sendHtmlMailWithAttachment(List<String> toAddress,
            String hostName, Integer smtpPort, String from, String username,
            String password, String subject, String htmlMessage,
            List<EmailAttachment> attachment) {
        // Create data information to compose the mail
        HtmlEmail email = new HtmlEmail();

        configureBasics(hostName, smtpPort, from, username, password, email, false);

        for (EmailAttachment attach : attachment) {
            try {
                email.attach(attach);
            } catch (EmailException e) {
                e.printStackTrace();
            }
        }

        email.setSubject(subject);
        try {
            email.setHtmlMsg(htmlMessage);
        } catch (EmailException e1) {
            e1.printStackTrace();
            return false;
        }
        email.setSSL(true);

        // send to all mails extracted from settings
        for (String add : toAddress) {
            try {
                email.addBcc(add);
            } catch (EmailException e) {
                e.printStackTrace();
                return false;
            }
        }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

  private Authenticator m_authenticator;

  private Logger m_logger;

  private HtmlEmail createHtmlEmail() throws EmailException {
    HtmlEmail email = new HtmlEmail();

    email.setHostName("smtp.gmail.com");
    email.setSmtpPort(465);
    email.setAuthenticator(m_authenticator);
    email.setSSL(true);
    email.setFrom(m_name);
    email.setCharset("utf-8");
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

  private boolean sendEmailByGmail(AlertMessageEntity message) {
    try {
      String title = message.getTitle();
      String content = message.getContent();
      List<String> emails = message.getReceivers();
      HtmlEmail email = createHtmlEmail();

      email.setSubject(title);
      email.setFrom("CAT@dianping.com");

      if (content != null) {
        email.setHtmlMsg(content);
      }
      if (emails != null && emails.size() > 0) {
        for (String to : emails) {
          email.addTo(to);
        }
        email.send();
      }
      return true;
    } catch (Exception e) {
      Cat.logError(e);
    }
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.