This commit is contained in:
xiangwb
2018-05-03 10:52:48 +08:00
parent a415fda150
commit cd872eea6b
8 changed files with 64 additions and 53 deletions
@@ -7,11 +7,13 @@ import com.xwbing.util.JsonResult;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.IOException;
/**
* 项目名称: sb-boot-module-demo
@@ -21,7 +23,7 @@ import javax.annotation.Resource;
*/
@Api(tags = "mailApi", description = "邮件测试相关接口")
@RestController
@RequestMapping("/mail/")
@RequestMapping("/mailtest/")
public class MailTestControl {
@Resource
private MailService mailService;
@@ -50,9 +52,12 @@ public class MailTestControl {
@LogInfo("发送带附件邮件")
@GetMapping("sendAttachmentsMail")
@ApiOperation(value = "发送带附件邮件")
public JSONObject sendAttachmentsMail() {
String path = "C:\\Users\\admin\\Desktop\\qq.txt";
RestMessage restMessage = mailService.sendAttachmentsMail("786461501@qq.com", "附件测试邮件", "收到一个带附件邮件", path);
public JSONObject sendAttachmentsMail() throws IOException {
ClassPathResource file = new ClassPathResource("file");
String path = file.getFile().getAbsolutePath();
String path1 = path + "\\QRCode.png";
String path2 = path + "\\QRCode.png";
RestMessage restMessage = mailService.sendAttachmentsMail("786461501@qq.com", "附件测试邮件", "收到一个带附件邮件", path1, path2);
return JsonResult.toJSONObj(restMessage);
}
@@ -62,7 +67,7 @@ public class MailTestControl {
public JSONObject sendInlineResourceMail() {
String rscId = "file";
String content = "<html><body>这是有图片的邮件:<img src=\'cid:" + rscId + "\'></body></html>";
String imgPath = "C:\\Users\\admin\\Desktop\\0000001.png";
String imgPath = "C:/Users/admin/Desktop/pic/0000001.png";
RestMessage restMessage = mailService.sendInlineResourceMail("786461501@qq.com", "内嵌图片测试邮件", content, imgPath, rscId);
return JsonResult.toJSONObj(restMessage);
}