コード例 #1
0
  @Async
  @Override
  public void mailToProsForUpdateRequestStatus(final WrapRequestService wrapRequestService) {

    logger.info(
        "mail to be sent for pros for updated status of service request      -"
            + "method name - mailToProsForUpdateRequestStatus  "
            + this.getClass().getSimpleName());
    for (final User list : wrapRequestService.getListProsForMail()) {

      if (list.isEnabled()) {

        try {
          MimeMessagePreparator preparator =
              new MimeMessagePreparator() {
                @SuppressWarnings({"rawtypes", "unchecked"})
                public void prepare(MimeMessage mimeMessage) throws Exception {
                  MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
                  //  message.setTo("*****@*****.**");
                  message.setTo(list.getEmailId());
                  // message.setBcc("*****@*****.**");

                  // message.setFrom(new InternetAddress(suggestedPodcast.getEmailId()) );
                  message.setFrom("Nearguru.com <*****@*****.**>");
                  message.setSubject(
                      wrapRequestService.getUser().getName()
                          + " has closed his "
                          + wrapRequestService.getProduct().getProductName()
                          + " request");
                  message.setSentDate(new Date());
                  Map model = new HashMap();
                  wrapRequestService.setProUser(list);
                  model.put("wrapRequestService", wrapRequestService);
                  model.put("professionalName", list.getName());
                  String text =
                      VelocityEngineUtils.mergeTemplateIntoString(
                          velocityEngine,
                          "com/doorit/spring/velocity/mailforUpdateRequestStatus.vm",
                          "UTF-8",
                          model);
                  message.setText(text, true);
                }
              };
          mailSender.send(preparator);
          logger.info(
              "mail  sent for pros for updated status of service request      -"
                  + "method name - mailToProsForUpdateRequestStatus  "
                  + this.getClass().getSimpleName());
        } catch (Exception e) {

          logger.info(
              "mail  sent for pros for updated status of service request  has error     -"
                  + "method name - mailToProsForUpdateRequestStatus  "
                  + this.getClass().getSimpleName()
                  + "   -"
                  + e.toString());
          e.printStackTrace();
        }
      }
    }
  }
コード例 #2
0
  @Async
  public void mailToProsForRequest(final WrapRequestService wrapQuotesMail) {
    // System.out.println(">>>>>>>>>>>>>pros profile email" +
    // wrapQuotesMail.getRequestService().getProdcutId());

    // List<User> user = this.prosService.getProsEmailIds(1);

    logger.info(
        "mail to be  sent to pros for   new service request      -"
            + "method name - mailToProsForRequest  "
            + this.getClass().getSimpleName());
    for (final User list : wrapQuotesMail.getListProsForMail()) {

      if (list.isEnabled()) {

        try {
          // wrapQuotesMail.setProUser(list);
          MimeMessagePreparator preparator =
              new MimeMessagePreparator() {
                @SuppressWarnings({"rawtypes", "unchecked"})
                public void prepare(MimeMessage mimeMessage) throws Exception {
                  MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
                  //  message.setTo("*****@*****.**");
                  message.setTo(list.getEmailId());
                  //   message.setBcc("*****@*****.**");

                  // message.setFrom(new InternetAddress(suggestedPodcast.getEmailId()) );
                  message.setFrom("Nearguru.com <*****@*****.**>");
                  message.setSubject(
                      wrapQuotesMail.getUser().getName()
                          + " is looking  for "
                          + wrapQuotesMail.getProduct().getProductName()
                          + " professional like you");
                  message.setSentDate(new Date());
                  Map model = new HashMap();
                  wrapQuotesMail.setProUser(list);
                  model.put("wrapRequestService", wrapQuotesMail);
                  model.put("professionalName", list.getName());
                  String text =
                      VelocityEngineUtils.mergeTemplateIntoString(
                          velocityEngine,
                          "com/doorit/spring/velocity/mailToProForUserRequest.vm",
                          "UTF-8",
                          model);
                  message.setText(text, true);
                }
              };
          mailSender.send(preparator);
          logger.info(
              "mail   sent to pro for   new service request      -"
                  + "method name - mailToProsForRequest  "
                  + this.getClass().getSimpleName());

        } catch (Exception e) {
          e.printStackTrace();
          logger.info(
              "mail to be  sent to pros for   new service request has error      -"
                  + "method name - mailToProsForRequest  "
                  + this.getClass().getSimpleName()
                  + "    -"
                  + e.toString());
        }
      }
    }

    /* get the listed pros for the service based on locality and send the mail to them */

  }