I have set up a MimeMessageHelper object to send email with attachment. My problem is when try to add a PDF attachment to the mail. The file is empty when received. There is no problem with other file format like TXT, and the content of the mail is also valid.
My code (I skip the config of the MimeMessageHelper since it seems to work):
MimeMessageHelper message = new MimeMessageHelper(...);
// ....
ClassPathResource resource = new ClassPathResource("mypdf.pdf");
File file = resource.getFile();
message.addAttachment(file.getName(), file);
How can I resolve this issue?