Win a copy of Murach's Python Programming this week in the Jython/Python 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
Hello,

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.setSubject(this.getMsgTitle());
email.setText(email.getContentType() +"\n"+ this.getMsg() );
Transport.send(email);
...

Thanks,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!