I have unicode for Simplified Chinese. I would like to send an email with Chinese subject and content. The content works fine-which converts unicode to Chinese, however the subject alwasys shows unicode instead of Chinese. Can anybody help? Enclosed you can see a part of my code:

session = Session.getInstance(props, null);
		MimeMessage message = new MimeMessage( session );
		message.setHeader("Content-Type", "text/plain; charset=UTF-8");

		message.setFrom( new InternetAddress( from ) ); 
		message.addRecipient( Message.RecipientType.TO, new InternetAddress( to ) ); 
		message.setSubject(subject, "text/plain; charset=utf-8"); 
		BodyPart messageBodyPart = new MimeBodyPart(); 
		messageBodyPart.setContent( content, "text/html; charset=utf-8" ); 

		Multipart multipart = new MimeMultipart(); 

		multipart.addBodyPart( messageBodyPart ); 

		message.setContent( multipart ); 

		Transport.send( message );


Edited 5 Years Ago by peter_budo: Keep It Clear - Do use code tags if posting any code

I also tried following code and it does not work:

message.setSubject(MimeUtility.encodeText("亲爱的用户", "UTF-8", "B"));

Please help.


I reviewed bioth links and I tried all possibilities and they do not work.

Any other suggestions?


This article has been dead for over six months. Start a new discussion instead.