I have implemented java mail with org.springframework.mail.javamail but while downloading from gmail it not downloading with file extension
below is my java code
private JavaMailSender mailSender;
MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws Exception {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true);
message.setTo("abc@gmail.com");
message.setFrom("sdf@gmail.com", "hello");
message.setText("text", true);
message.setSubject("subject");
message.addAttachment("name", file);
}
};
try {
mailSender.send(preparator);
} catch (Exception ex) {
ex.printStackTrace();
}
as we can see in first image it showing as excel file but when we download it, its downloading as file please see the second image please help me if any thing missing or suggest any changes required
Edited
I am Creating file as File outputFl = new File("filepath/finaleName.xls");