当前位置:   article > 正文

java定时任务:oracle导出excel后,发送excel作为附件的邮件_oracle如何写定时发有excel文件的邮件

oracle如何写定时发有excel文件的邮件

定时任务类:

  1. package com.cairenhui.sec.task;
  2. import java.io.File;
  3. import java.io.FileOutputStream;
  4. import java.io.OutputStream;
  5. import java.io.UnsupportedEncodingException;
  6. import java.net.URLEncoder;
  7. import java.util.Date;
  8. import java.util.List;
  9. import java.util.Map;
  10. import javax.mail.internet.MimeMessage;
  11. import org.apache.log4j.Logger;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.core.io.FileSystemResource;
  14. import org.springframework.mail.javamail.JavaMailSenderImpl;
  15. import org.springframework.mail.javamail.MimeMessageHelper;
  16. import org.springframework.stereotype.Component;
  17. import com.cairenhui.sec.service.ObsUserHkInfoService;
  18. import com.cairenhui.sec.util.ExcelUtil;
  19. import com.cairenhui.sec.utils.PropertiesUtils;
  20. /**
  21. *
  22. * @author jinxd 2014-12-29 从数据库中导出excel,然后调用邮件发送接口,发送邮件
  23. */
  24. @Component
  25. public class HKTask {
  26. @Autowired
  27. private ObsUserHkInfoService obsUserHkInfoService;
  28. @Autowired
  29. private JavaMailSenderImpl mailSender;
  30. private static final Logger log = Logger.getLogger(HKTask.class);
  31. /**
  32. * 港股通业务,通过OBS_USER_HK_INFO表,每天23:55导出excel,并发送邮件
  33. */
  34. public void sendHKInfoEmailJob() {
  35. long t1 = System.currentTimeMillis();
  36. log.info("-------------- 执行港股通定时任务 start --------------------" + t1);
  37. try {
  38. @SuppressWarnings("unchecked")
  39. List<Map<String, Object>> list = obsUserHkInfoService.findTheSameDay();// 查询数据
  40. if (list.size() > 0) {
  41. StringBuilder fileName = new StringBuilder();
  42. String name = "HKStockCount_" + (new Date()).getTime();// 表格名字
  43. String encoderName = "";
  44. try {
  45. encoderName = URLEncoder.enc
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/591754
推荐阅读
相关标签
  

闽ICP备14008679号