Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail: encoding ISO-8859-1  RSS feed

Regis Santos
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm trying to send a message using the javax.mail API. The problem is that the message contains latin characters (�, �, �), but on the message they are replaced by '?'

I've set the Content-Type on the header of the message calling
setHeader("Content-Type","text/plain; charset=ISO-8859-1"), but it has no effect.

MimeMessage email = new MimeMessage(session);
email.setHeader("Content-Type", "text/plain; charset=ISO-8859-1");
email.setContentLanguage(new String[] {"pt-br"});
email.setFrom(new InternetAddress(this.getMsgFrom()));
email.addRecipient(Message.RecipientType.TO , new InternetAddress(msgTo));
email.setText(email.getContentType() +"\n"+ this.getMsg() );

Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!