I'm using Javamail to send email, with attachment, on Android.
When attaching a file with a ".txt" extension, it is assigning the content to the email body, not as an attached file.
My code for file attachments:
public void addAttachment(String filename) throws Exception {
DataSource file = new FileDataSource(filename);
BodyPart attachment = new MimeBodyPart();
attachment.setDataHandler(new DataHandler(file));
attachment.setFileName(filename);
multipart.addBodyPart(attachment);
}
I did a test by changing the file extension to ".tx" and it was attached as a file. How do I attach the ".txt" as a file?