• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaMail: encoding ISO-8859-1

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic