JavaMail API - 使用Freemarker模板发送表情符号/笑脸?

时间:2015-03-31 12:46:50

标签: spring spring-mvc javamail freemarker

我在春天开发了rest API。

我必须通过表情符号向用户发送邀请邮件。

我开发的.ftl和.java配置文件如下:

invitation.ftl

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
//Content
</body>
</html>

webAppConfi.java

@Bean
public FreeMarkerConfigurationFactoryBean freeMarkerConfigurationFactoryBean() {
    FreeMarkerConfigurationFactoryBean freeMarkerConfigurationFactoryBean = new FreeMarkerConfigurationFactoryBean();
    freeMarkerConfigurationFactoryBean
            .setTemplateLoaderPath("/WEB-INF/templates/mail/");
    freeMarkerConfigurationFactoryBean.setDefaultEncoding("UTF-8");
    return freeMarkerConfigurationFactoryBean;
}

sendMail.java

    MimeMessage message = null;
    MimeMessageHelper objHelper = null;
    String strBody = null;
    try {

        strBody = FreeMarkerTemplateUtils.processTemplateIntoString(
                freemarkerMailConfiguration.getTemplate(templetName),
                templateProp);
        message = this.mailSender.createMimeMessage();
        objHelper = new MimeMessageHelper(message, true);
        objHelper.setTo(to);
        objHelper.setText(strBody, true);
        objHelper.setSubject(subject);
        mailSender.send(message);
        }
        finally{}

我从iPhone \ ud83d \ ude14 \ ud83d \ ude17获取类似的字符串。

那么我怎么能将这个表情符号值发送到电子邮件正文部分呢?

谢谢!

0 个答案:

没有答案