springboot发送复杂邮件

springboot发送复杂邮件

@Resource
JavaMailSenderImpl javaMailSender;
public void sendEmail (String targetEmail,String content) {
        MimeMessage mimeMessage=javaMailSender.createMimeMessage();
        try {
            MimeMessageHelper helper=new MimeMessageHelper(mimeMessage);
            //邮件主题
            helper.setSubject("下班提示小助手");
            //邮件内容
            helper.setText(content,true);
            //发件人邮箱
            helper.setFrom("自律<>");
            //收件人邮箱
            helper.setTo(targetEmail);
            //发送
            javaMailSender.send(mimeMessage);
            System.out.println("成功");
        }catch (Exception e){
            e.getStackTrace();
            System.out.println("失败");
        }
    }
}

发件内容

<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<style>
		h1{
			width: auto;
			font-size:-webkit-xxx-large;
			color: red;
			text-align: center;
		}
		img{
			margin-top: 20px;
		}
	</style>
	<body>
		<h1 >下班啦</h1>
		<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.bczp.cn%2Fuploadfiles%2Fhtml%2F20131205120236_0150.jpg&refer=http%3A%2F%2Fpic.bczp.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661064121&t=f8e8cd17d40c3409b7c58ecb1f9118f1" >
		<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F12957320047%2F641.jpg&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661064055&t=ae8d6a2071ab45109f112908d53c7af0">
		<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20190928%2F0115346a16a44a51bb62a6a07c29fab6.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661063672&t=a77cf482ac2383498088f201da08cbdd"/>		
	<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.adoutu.com%2Fpicture%2F1538231189795.gif&refer=http%3A%2F%2Fimg.adoutu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661063973&t=a780e511ff19c60b7c6e8b47b741d907"/>
	</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只代码小白啦啦啦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值