java实现定时发送邮件实现定时发送邮件
前几天,需要做一个功能就是 客户使用我们公司的设备的时候 ,每天固定一个时间点 ,我们定时发送该设备的数据到客户邮箱,让客户了解自己设备的一个情况,由于代码不能上传,就
把当时我开始搭建开发而写的一个demo记录下来,实现的原理是一样的,非常之简单.
一.创建一个springboot的项目
项目结构图:
首先首先,我们先测试邮件发送我们先测试邮件发送
controller层
package com.csq.study.controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.TemplateEngine;
import com.csq.study.service.SendMailService;
import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.context.Context;
import java.io.File;
import java.util.ArrayList;
@RestController
public class SendMailController {
@Autowired
评论0