我们目前正在研究一个缺陷,以允许在电子邮件主题中看到特殊符号。该电子邮件是text/html MIME类型。电子邮件主题中的特殊符号
目前,如果主题应该有心脏符号,它会显示为“&心脏”,但在电子邮件正文中会显示“心脏”符号。
有人可以帮助我们解决方案有特殊符号也是主题的一部分吗?
这是代码片段。
public boolean send(String to, String from, String subject, String templatePath, Map map) {
// create a mime message using the mail sender implementation
MimeMessage mimeMessage = mailSender.createMimeMessage();
// create the message using the specified template
MimeMessageHelper helper;
try
{
helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setTo(to);
helper.setSubject(subject);
helper.setFrom(from);
String text = VelocityEngineUtils.mergeTemplateIntoString(engine, templatePath, map);
helper.setText(text, true);
send(mimeMessage);
log.debug("in send at start" + this.getClass().getName()
+ ":SUCCESS: Sendig mail to" + to + " from " + from + " subject "
+ subject);
} catch (MessagingException e)
{
throw new MailPreparationException("unable to create the mime message helper", e);
} catch (Exception e)
{
log.debug("in send at start" + this.getClass().getName() + ":Failed sending mail"
+ to + " from " + from + " subject " + subject);
// throw new
// MailPreparationException("unable to create the mime message helper",
// e);
}
return false;
} 公共布尔发送(的MimeMessage的MimeMessage)抛出异常{
try
{
Multipart multipart = new MimeMultipart();
BodyPart bodyPart = new MimeBodyPart();
multipart.addBodyPart(bodyPart);
bodyPart.setContent(mimeMessage.getContent(), "text/html");
mimeMessage.setContent(multipart);
mailSender.send(mimeMessage);
} catch (Exception e)
{
log.error("in send at start" + this.getClass().getName() + ":Failed sending mail"
+ e.getMessage());
// e.printStackTrace();
throw e;
// return false;
}
return true;
}
请接受一些你曾经问过的问题的答案 - 你会发现人们更愿意帮助你,这使得StackOverflow变得更加美好。 – 2011-05-09 16:43:39