Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaMail: encoding ISO-8859-1

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() );

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic