My application has to send a textfile, which it first has to generate as a String. The text contains non-ASCII symbols, so i would like it to be UTF-8. I\'ve tried a lot of vari
Set the content type to application/octet-stream:
MimeBodyPart attachmentPart = new MimeBodyPart();
try {
DataSource ds = new ByteArrayDataSource(attachment.getBytes("UTF-8"), "application/octet-stream");
attachmentPart = new MimeBodyPart();
attachmentPart.setDataHandler(new DataHandler(ds));
}
catch (Exception e) {
Logger.getLogger("Blina").log(Level.SEVERE, Misc.getStackTrace(e));
}
attachmentPart.setFileName(fileName);
multipart.addBodyPart(attachmentPart);
// Put parts in message
msg.setContent(multipart);