@Test
public void sendAttachedFileMail() throws Exception{
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage,true,"utf-8");
mimeMessageHelper.setTo("18701781651@163.com");
mimeMessageHelper.setFrom("18701781651@163.com");
mimeMessageHelper.setSubject("Spring Boot Mail 邮件测试【附件】");
StringBuilder sb = new StringBuilder();
sb.append("<html><head></head>");
sb.append("<body><hl>spring 邮件测试</hl><p>Hello,this is a spring mail test.");
sb.append("</p></body></html>");
mimeMessageHelper.setText(sb.toString(),true);
FileSystemResource file = new FileSystemResource(new File("E:/config.ini"));
mimeMessageHelper.addAttachment("config.ini",file );
javaMailSender.send(mimeMessage);
}
springboot集成JMS含附件邮件发送
最新推荐文章于 2024-01-24 16:14:31 发布