HI,I'm working on a JSF application with Velocity which I use for email sending
in text, not in HTML. I have some problems with accentuated characters (à, é, è
...) or specials characters in general (€ for example). I use some java to get
the content of the email like this: public String
getCorpsClient(RecapitulatifCommandeDTO recapCmd, String cid) { String getCorps
= "getCorps : "; String pCorps = null; configure(engine); Template template;
try { template = engine.getTemplate(buildFileName(FILE_RECAP_CMD, recapCmd));
VelocityContext context = createContext(); context.put(VAR_RECAP_CMD,
recapCmd); context.put(VAR_CID, cid); StringWriter writer = new StringWriter();
template.merge(context, writer); pCorps = writer.getBuffer().toString();
writer.close(); } catch (ResourceNotFoundException rnfe) {
logger.error(getCorps + rnfe); throw new TechnicalException(noTemplateVelocity,
rnfe); } catch (ParseErrorException pe) { logger.error(getCorps + pe); throw
new TechnicalException(parseErrorTemplateVelocity, pe); } catch (Exception e) {
logger.error(getCorps + e); throw new TechnicalException(techExceptionVelocity,
e); } return pCorps; } My function which send the email. I've tested many
values for ENCODAGE without any changes.public boolean
sendHtmlEmailOubliPassWord(String toMail, String toName,String fromMail, String
fromName, String subject, String corps) {boolean result = false;Session session
= getMailSession();SimpleEmail email = new
SimpleEmail();email.setMailSession(session);email.setSentDate(new
Date());email.setCharset(ENCODAGE);try {email.addTo(getMockEmail(toMail),
toName);email.setFrom(fromMail,
fromName);email.setSubject(subject);email.setMsg(corps);email.send();result =
true;} catch (EmailException ee) {logger.error("Erreur sendSimpleMail : " + ee
+ "\n"+ ee.getCause());}return result;}My velocity.properties if it can
help:resource.loader = classclass.resource.loader.description = Velocity Class
Resource Loaderclass.resource.loader.class =
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader# Cette
partie n'est pas utilis?(pas r?renc?dans
resource.loader)file.resource.loader.description = Velocity File Resource
Loaderfile.resource.loader.class =
org.apache.velocity.runtime.resource.loader.FileResourceLoader#file.resource.loader.path
= D:/bdf/workspace/Suren2/web/static/template/file.resource.loader.path
=file.resource.loader.cache =
falsefile.resource.loader.modificationCheckInterval = 2Instead of giving me
some accentuated characters, I get some ? which makes the email dirty. Could
you please give me a way to find how to resolve my problem? Best regards,
_________________________________________________________________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créez un compte.
http://www.windowslive.fr/hotmail/default.asp