Spring Mail内联图像在Mac Mail中不起作用

时间:2016-06-08 07:15:06

标签: spring macos email

当我使用Spring发送邮件内联图像时,我发现它不会在Mac Mail App中显示图像,但它会在Web Zimbra中显示。我的代码如下,它有什么问题?

JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setDefaultEncoding("UTF-8");
mailSender.setHost(Consts.MAIL_HOST);
mailSender.setUsername(Consts.MAIL_USER);
mailSender.setPassword(Consts.MAIL_PASSWORD);
MimeMessage msg = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(msg, true, "UTF-8");
helper.setFrom(mailSender.getUsername());
InternetAddress[] addresses = InternetAddress.parse("sartisty@gmail.com");
helper.setTo(addresses);
helper.setSubject("test");
helper.setText("<html><body><img src='cid:identifier1234'></body></html>", true);
FileSystemResource res = new FileSystemResource(new File("/Users/yanshuai/widget-ca3dc599-9c30-43de-9a2d-b62903301b59.png"));
helper.addInline("identifier1234", res);
mailSender.send(msg);

0 个答案:

没有答案