PDA

View Full Version : VelocityEngineUtils question


kmthien
Feb 8th, 2006, 09:02 PM
Hi guys,

I m using spring 1.2.6 and my code (from appfuse) is like below:

public void sendMessage(SimpleMailMessage msg, String templateName,
Map model) {
String result = null;

try {
result =
VelocityEngineUtils.mergeTemplateIntoString(veloci tyEngine,
templateName, "UTF-8", model);
} catch (VelocityException e) {
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}

msg.setText(result);
send(msg);
}

I have put UTF-8 as a unicode encoding but when user received the email,
those Chinese character are like ????????????. All garble up ! Pls help, Thanks !

Apologize if I posted on the wrong section.

ojs
Feb 9th, 2006, 04:58 AM
I have put UTF-8 as a unicode encoding but when user received the email, those Chinese character are like ????????????. All garble up !

You have to configure your JavaMailSenderImpl to use UTF-8 as encoding for emails.

I did this with:


<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderIm pl">
<property name="host" value="localhost"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>



HTH
Oliver

kmthien
Feb 14th, 2006, 09:51 PM
Thanks a lot man ! it works !