Exemple #1
0
  /**
   * @param job
   * @param mailManager
   * @param currentUserEmail
   */
  public static void sendAdminEmail(EmailManager mailManager, CustomerCareForm customerCareForm) {

    String fromMailAddressForHolden = PropertyManager.getProperty("mail.from.holden");

    String subject = "Customer Care";

    StringBuilder sb = new StringBuilder();
    sb.append("<html><body>");
    sb.append("<b>Topic: Customer Care</b>");
    sb.append("<br><br>");

    sb.append("Name : " + customerCareForm.getFirstName() + " " + customerCareForm.getLastName());
    sb.append("<br><br>");

    sb.append("E-Mail Address : " + customerCareForm.getEmail());
    sb.append("<br><br>");

    sb.append("Phone No. : " + customerCareForm.getPhone());
    sb.append("<br><br>");

    sb.append("Preferred Contact Time : " + customerCareForm.getPreferredContactTime());
    sb.append("<br><br>");

    sb.append("Message body : " + customerCareForm.getComments());
    sb.append("<br><br>");

    sb.append("<br>");
    sb.append("</body></html>");

    // get from the properties
    String adminEmails = PropertyManager.getProperty("mail.admin");

    Set<String> alltoMails = new HashSet<String>();

    String[] temp = adminEmails.split(";");
    for (int cnt = 0; cnt < temp.length; cnt++) {
      alltoMails.add(temp[cnt]);
    }

    for (String toMail : alltoMails) {
      try {
        boolean success =
            mailManager.sendMail(
                toMail,
                fromMailAddressForHolden,
                fromMailAddressForHolden,
                subject,
                sb.toString(),
                "charset=UTF-8",
                new ArrayList<Attachment>());
        System.out.println("email send success ? " + success);
        logger.info("email send success ? " + success);
      } catch (Exception e) {
        logger.error("email send falided  ", e);
        throw new RuntimeException(
            "There is the error when sending the email, please try again later.");
      }
    }
  }
Exemple #2
0
  public static void sendCustomerEmail(
      EmailManager mailManager, CustomerCareForm customerCareForm) {

    String fromMailAddressForUser = PropertyManager.getProperty("mail.from.user");
    String subject = "Customer Care";

    StringBuilder sb = new StringBuilder();
    sb.append("<html><body>");

    sb.append("Hi!");
    sb.append("<br><br>");
    sb.append("Thanks for submitting your feedback form to us. ");
    sb.append("<br><br>");
    sb.append("We will review your request as soon as possible and get in touch. ");
    sb.append("<br><br>");
    sb.append("Regards,");
    sb.append("<br>");
    sb.append("Customer Assistance team");
    sb.append("</body></html>");

    try {
      boolean success =
          mailManager.sendMail(
              customerCareForm.getEmail(),
              fromMailAddressForUser,
              fromMailAddressForUser,
              subject,
              sb.toString(),
              "charset=UTF-8",
              new ArrayList<Attachment>());
      System.out.println("CustomerEmail send success ? " + success);
      logger.info("CustomerEmail send success ? " + success);
    } catch (Exception e) {
      logger.error("CustomerEmail send falided  ", e);
      throw new RuntimeException(
          "There is the error when sending the CustomerEmail , please try again later.");
    }
  }