简体   繁体   中英

Encode accented characters from http request to email body

Good day.

I have a Java Tomcat's application the allow to compile a form where there is a textarea field. The submit go to a servlet where the request fields are read and and e-mail to send is composed. In order to send e-mail I use JavaMail. The textarea field is inserted in the setText method of the MimeMessage class. When I receive the e-mail in my client the accented characters are visbile as? (question mark). "Avrei bisogno di più informazione sull'immobile ed in particolare sulla sua qualità e ricevere delle foto." "Avrei bisogno di pi? informazione sull'immobile ed in particolare sulla sua qualit? e ricevere delle foto."

Consider that the jsp page is UTF-8 econded and also the servlet processRequest start with request.setCharacterEncoding("UTF-8"); Infact if I put the value in MySql table I haven't problems.

How can I resolve the problem?

Best regards.

Stefano Errani

Try that:

MimeMessage msg = new MimeMessage(your session);
msg.setContent(your content, "text/html; charset=utf-8");

I hope, it will help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM