It works fine without the multi-part (modified from the example in Spring documentation):
final MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(final MimeMessage mimeMessage) throws Exception {
final MimeMessageHelper message = new MimeMessageHelper(
mimeMessage);
message.setTo(toAddress);
message.setFrom(fromAddress);
message.setSubject(subject);
final String htmlText = FreeMarkerTemplateUtils
.processTemplateIntoString(configuration
.getTemplate(htmlTemplate), model);
message.setText(htmlText, true);
}
};
mailSender.send(preparator);
But once I change it to:
final MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(final MimeMessage mimeMessage) throws Exception {
final MimeMessageHelper message = new MimeMessageHelper(
mimeMessage, true);
...
message.setText(plainText, htmlText);
}
};
mailSender.send(preparator);
I get:
Failed message 1:
javax.mail.MessagingException: Converting attachment data failed
at com.google.appengine.api.mail.stdimpl.GMTransport.sendMessage(GMTransport.java:231)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:402)
...
Since the GMTransport
is a proprietary Google class and no source is available, it's pretty difficult to figure out the problem (at least with my skills). Anyone have any ideas what to try next?
My bean config, for helping you to help me:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"
p:username="${mail.username}" p:password="${mail.password}"
p:protocol="gm" />