Avatar of dkim18
dkim18
 asked on

Sending email in Chinese

Hi,

I am trying to send email in Chinese, but the below code only sends body part garbled message.

try{               
                            sun.net.smtp.SmtpClient smtp = new sun.net.smtp.SmtpClient("smtp.xxxx.org");
                            smtp.from((String)ResourceUtils.getResourceValue("xxx.replyEmail"));
                            smtp.to(to);
                            PrintStream msg = smtp.startMessage();
                          
                            msg.println("To: " + to);
                            msg.println("Subject: "+subject);
                            msg.println();//start of the body :
                            msg.println(body);
                            smtp.closeServer(); //sent
                }catch(Exception e){
                	log.error(e);                   
                }

Open in new window


I debugged that body variable contains correct Chinese characters.
Any ideas?

thanks,
Java

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
Am P

dkim18

ASKER
I get null pointer exception.

out.println(new String(request.getParameter("inputText").  
                         getBytes("ISO-8859-1"), "UTF-8")) ;
dkim18

ASKER
well..it does send an email, but I see whole bunch of question marks in the email.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
CEHJ

Use JavaMail, not that (unsupported) class
ASKER CERTIFIED SOLUTION
Am P

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

?