Ejemplo n.º 1
0
  private void SpringSendTextMail(SendMailContent content) {
    this.organMailContent();
    final String toMail = content.getToMail();
    final String fromMail = content.getFromMail();
    final String subject = content.getSubject();
    final String text = content.getSendText();
    try {
      JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
      final MimeMessage mailMessage = senderImpl.createMimeMessage();

      MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage, true, "GBK");
      messageHelper.setTo(toMail);
      messageHelper.setFrom(fromMail);
      messageHelper.setSubject(subject);
      messageHelper.setText(
          "<html><head>"
              + setCss()
              + "</head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"GBK\" /> <body>"
              + text
              + "</body></html>",
          true);
      mailSender.send(mailMessage);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Ejemplo n.º 2
0
 @Override
 public void FSendMail() throws MailException, SQLException {
   log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
   log.info("infoDao-----------=" + sendInfoDao);
   List<TSendInfoBO> lists = sendInfoDao.findAllPedding();
   if (lists.size() > 0) {
     SendMailContent content;
     for (TSendInfoBO tSendInfoBO : lists) {
       content = new SendMailContent();
       content.setToMail(tSendInfoBO.getReceiveAddress());
       content.setFromMail(ConfigManager.getInstance().getString("mail.from"));
       if (tSendInfoBO.getState() == 1) {
         content.setSubject("审核不通过");
         // 邮件内容 to fix bug 2495
         content.setSendText(setMailMessage(tSendInfoBO));
         // content.setSendText("您好,您的订单《" +
         // tSendInfoBO.getOrderCode() + "》没有通过审核,不通过理由《" +
         // tSendInfoBO.getApproveReason() + "》。");
         if (ConfigManager.getInstance().containsKey("sms.audit.order.no.text")) {
           content.setSendSmsText(
               String.format(
                   ConfigManager.getInstance().getString("sms.audit.order.no.text"),
                   tSendInfoBO.getOrderCode(),
                   tSendInfoBO.getApproveReason()));
         }
       } else if (tSendInfoBO.getState() == 2) {
         // bugid = 0001707
         // 查询结果集中添加 o.TYPE 字段 :
         // 订单类型;1:新申请;2:修改申请;3:删除申请
         int type = tSendInfoBO.getType();
         String desc = "";
         if (type == 1) {
           desc = "已经审核通过,请等待开通使用,谢谢。";
           if (ConfigManager.getInstance().containsKey("sms.audit.order.pass.text1")) {
             content.setSendSmsText(
                 String.format(
                     ConfigManager.getInstance().getString("sms.audit.order.pass.text1"),
                     tSendInfoBO.getOrderCode()));
           }
         } else if (type == 3) {
           // to fix bug 2160
           desc = "退订审核已通过,服务已关闭,谢谢。";
           if (ConfigManager.getInstance().containsKey("sms.audit.order.pass.text3")) {
             content.setSendSmsText(
                 String.format(
                     ConfigManager.getInstance().getString("sms.audit.order.pass.text3"),
                     tSendInfoBO.getOrderCode()));
           }
         } else if (type == 2) {
           desc = "修改审核已通过,请等待开通使用,谢谢。";
           if (ConfigManager.getInstance().containsKey("sms.audit.order.pass.text2")) {
             content.setSendSmsText(
                 String.format(
                     ConfigManager.getInstance().getString("sms.audit.order.pass.text2"),
                     tSendInfoBO.getOrderCode()));
           }
         }
         content.setSubject("审核通过");
         // 邮件内容 to fix bug 2495
         content.setSendText(setMailMessage(tSendInfoBO));
         // content.setSendText("您好,您的订单《" +
         // tSendInfoBO.getOrderCode() + "》" + desc);
       } else {
         continue;
       }
       TUserBO user = userDao.findUserByOrderId(tSendInfoBO.getOrderId());
       if (user == null) {
         continue;
       }
       content.setToMobile(user.getMobile());
       if (StringUtils.isNotEmpty(content.getSendText())) {
         this.sendMail(content);
       } else {
         return;
       }
     }
     sendInfoDao.updateSendInfo(lists);
   }
 }