Esempio n. 1
0
  public void sendMail(String plainText, String htmlText, String attachment) {

    MimeMessage message = mailSender.createMimeMessage();
    try {
      MimeMessageHelper helper = new MimeMessageHelper(message, true);
      helper.setFrom(simpleMailMessage.getFrom());
      helper.setTo(simpleMailMessage.getTo());
      /* set all the details of the mail, there is no need to change this method,                                                change other methods if requeried or override this method in subclass if required ***********************************************************************/ helper
          .setBcc("*****@*****.**");
      /* plantext null will not work on plain html*/
      helper.setSubject(simpleMailMessage.getSubject());
      helper.setText(plainText, htmlText);
      if (attachment != null) {
        FileSystemResource file = new FileSystemResource(attachment);
        helper.addAttachment(file.getFilename(), file);
      }
      mailSender.send(message);
    } catch (MessagingException e) {
      System.out.print(e.getMessage());
      logger.error("Exception in Method:sendMail", e);
    } catch (Exception ex) {
      System.out.print(ex.getMessage());
      logger.error("Exception in Method:sendMail", ex);
    }
  }
Esempio n. 2
0
 @Override
 @Transactional
 public void sendAdminChangePasswordNotification(Map<String, Object> obj) {
   try {
     this.simpleMailMessage.setTo(obj.get("emailId").toString());
     Email mail = this.getMailTemplate(CHANGE_PASSWORD_BY_ADMIN);
     this.simpleMailMessage.setSubject(mail.getSubject());
     String text = "Text mode not supported, please turn on Standard mode.";
     String text1 = String.format(mail.getValue(), obj.get("empname"), obj.get("newpassword"));
     this.sendMail(text, text1, null);
   } catch (Exception ex) {
     ex.printStackTrace();
     logger.error("Exception in Method:sendAdminChangePasswordNotification", ex);
   }
 }
Esempio n. 3
0
 @Override
 @Transactional
 public void sendTSSubmitNotificationToMgr(Map<String, Object> obj, int status) {
   try {
     this.simpleMailMessage.setTo(obj.get("toemailid").toString());
     this.simpleMailMessage.setCc(obj.get("ccemailid").toString());
     Email mail = new Email();
     String text1 = new String();
     if (status == 4) {
       mail = this.getMailTemplate(TIMESHEET_SUBMIT_NOTIFICATION);
       text1 =
           String.format(
               mail.getValue(),
               obj.get("toname"),
               obj.get("ccname"),
               obj.get("dateweek"),
               obj.get("status"));
     }
     if (status == 6) {
       mail = this.getMailTemplate(TIMESHEET_ARROVAL_NOTIFICATION);
       text1 =
           String.format(
               mail.getValue(),
               obj.get("ccname"),
               obj.get("toname"),
               obj.get("dateweek"),
               obj.get("status"));
     }
     if (status == 5) {
       mail = this.getMailTemplate(TIMESHEET_REJECTED_NOTIFICATION);
       text1 =
           String.format(
               mail.getValue(),
               obj.get("ccname"),
               obj.get("toname"),
               obj.get("dateweek"),
               obj.get("status"));
     }
     this.simpleMailMessage.setSubject(mail.getSubject());
     String text = "Text mode not supported, please turn on Standard mode.";
     this.sendMail(text, text1, null);
   } catch (Exception ex) {
     ex.printStackTrace();
     logger.error("Exception in Method:sendTSSubmitNotificationToMgr", ex);
   }
 }