Example usage for org.apache.commons.mail HtmlEmail setContent

List of usage examples for org.apache.commons.mail HtmlEmail setContent

Introduction

In this page you can find the example usage for org.apache.commons.mail HtmlEmail setContent.

Prototype

public void setContent(final Object aObject, final String aContentType) 

Source Link

Document

Set the content and contentType.

Usage

From source file:io.mif.labanorodraugai.services.EmailService.java

public void SendInvitationEmail(Account sender, String toEmail) throws EmailException, MalformedURLException {
    //ImageHtmlEmail email = new ImageHtmlEmail();
    HtmlEmail email = new HtmlEmail();
    setUpHtmlEmail(email);/*from  w  ww .j  av  a 2 s  .c om*/
    email.addTo(toEmail);
    email.setSubject("Labanoro draug kvietimas");

    StringBuilder msg = new StringBuilder();
    //msg.append("<div><img src=\"" + baseUrl + "/images/lab  anorodraugai.JPG\"></div>");
    msg.append("<h4>Sveiki,</h4>");
    msg.append("<p>" + sender.getName() + " " + sender.getLastname()
            + " kvie?ia Jus tapti bendrijos Labanoro draugai nariu!</p>");
    msg.append("<p>T padaryti galite usiregistrav ");
    msg.append("<a href=" + "\"http://localhost:8080/LabanoroDraugai/registration/registration.html\">");
    msg.append("?ia</a></p>");

    email.setContent(msg.toString(), EmailConstants.TEXT_HTML);

    email.send();
}

From source file:io.mif.labanorodraugai.services.EmailService.java

public void sendApprovalRequestEmail(AccountApproval approval) throws EmailException, MalformedURLException {
    HtmlEmail email = new HtmlEmail();
    setUpHtmlEmail(email);// w w  w .ja  v  a2  s .co m
    email.addTo(approval.getApprover().getEmail());
    email.setSubject("Naujo nario rekomendacija");

    Account candidate = approval.getCandidate();

    StringBuilder msg = new StringBuilder();
    //msg.append("<div><img src=\"" + baseUrl + "/images/lab  anorodraugai.JPG\"></div>");
    msg.append("<h4>Sveiki,</h4>");
    msg.append("<p>" + candidate.getName() + " " + candidate.getLastname() + " (" + candidate.getEmail()
            + ") nori tapti Labanoro Draugai nariu ir prao Js suteikti rekomendacij!</p>");
    msg.append("<p>T padaryti galite: ");
    msg.append("<a href=" + "\"http://localhost:8080/LabanoroDraugai/registration/approval.html?gen="
            + approval.getGeneratedId() + "\">");
    msg.append("?ia</a></p>");

    email.setContent(msg.toString(), EmailConstants.TEXT_HTML);

    email.send();
}