Email subject in localization received wrongly

Hello,

I have a problem to dispay the email subject with localization characters in GAE/GWT deployment evironment (appspot.com). e.g. Frech. Please see the code below:


	Properties props = new Properties(); 
	
	Session mailSession = Session.getDefaultInstance(props, null);
	mailSession.setDebug(true);
	
	MimeMessage message = new MimeMessage(mailSession);
	message.setFrom(new InternetAddress(CFG_MAILFROM));

	title = MimeUtility.encodeText(title);
	message.setSubject(title);

	message.setText(htmlContent);
	message.addRecipient(Message.RecipientType.TO, new InternetAddress(address));

	Transport.send(message);

If I send the subject “titre en français”, I will receive “titre en fran?ais”. It looks like the famous encoding issue, but the code (more config should be added) works fine in Eclipse Tomcat development evironment.

So, it is really puzzled me. If you have any idea, please let me know.

Thanks in advance.

I would try setting explicitly the encoding to UTF-8, using the second parameter in the encodeText() call.
Your other alternative is to strip the accents in the Subject header – many systems don’t process them correctly anyway, no matter what the standards say.

In order to strip accents, the easiest way is to do (for older Java, the Normalizer API is slightly different, Google it up)

java.text.Normalizer.normalize(s, java.text.Normalizer.Form.NFD);

Thank you, Jean! The first solution works.