I am trying to create an automated mailing system. As attachments what I get in return calling the methods of the component, which I don't have access to it's source code is a Springframework MultipartFile object. Is there any way to attach this object in a Java mail object or is there a way to convert a Springframework MultipartFile object to javax.mail.Multipart object ?
If you take a look here:
http://www.codejava.net/frameworks/spring/spring-mvc-send-e-mail-with-attachments
At line 55 they have an example of how you can do this. You need to implement InputStreamSource - but its very straight forward.
messageHelper.addAttachment(attachName, new InputStreamSource() {
@Override
public InputStream getInputStream() throws IOException {
return attachFile.getInputStream();
}
});
}
messageHelper is a MimeMessageHelper
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.