邮件增加附件时候,报错JavaMail requires an InputStreamSource that creates a fresh stream for every call.
InputStreamResource inputStreamResource = new InputStreamResource(new URL(url).openStream());
mimeMessageHelper.addAttachment(
"wsktn.docx", inputStreamResource
);
解决方式,使用IOUtils.toByteArray 读取后,ByteArrayResource包装解决此问题
ByteArrayResource byteArrayResource = new ByteArrayResource(IOUtils.toByteArray(new URL(url).openStream()));
mimeMessageHelper.addAttachment(
"wsktn.docx", byteArrayResource
);