I am trying to send an e-mail with a PDF as an attachment. It was including the file but its size was less than what it was on disk, and when trying to open it, it says the file is corrupted.
MimeBodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
messageBodyPart = new MimeBodyPart();
try {
messageBodyPart.attachFile(new File(filePath+"/"+fileName), "application/pdf", null);
String message = "file attached. ";
messageBodyPart.setContent(message, "text/html");
multipart.addBodyPart(messageBodyPart);
mail.setMultiBody(multipart);