@Test // send message complexity void contextLoads2 () throws MessagingException { MimeMessage mimeMessage = mailSender.createMimeMessage(); //组装 MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true); //正文 helper.setSubject("xxx你好啊"); helper.setText ( "<style = h1 of 'Color: Red'> row down the road Java </ h1 of>", to true ); // Annex helper.addAttachment ( "baby Kay .jpg", new new File ( "C : the Users \\ Desktop \\ \\ \\ PC favicon.ico " )); helper.addAttachment("莱纳德.jpg",new File("C:\\Users\\pc\\Desktop\\favicon.ico")); helper.setTo("[email protected]"); helper.setFrom("[email protected]"); mailSender.send(mimeMessage); }