Tuesday, March 15, 2011

Sending MimeMultipart emails on Google App Engine

After some trial and error, I found that the example from google (here was not sufficient.
javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Converting attachment data failed)


I then found an example suggesting adding setDispostion on the BodyPart to Part.ATTACHMENT and thought that was a step in the right direction. But still it did not work.

Then as a last resort (and because I noticed they were using a DataHandler import in the example, that they were not using in the code) I tried the ByteArrayDataSource on the data and used setDataHandler instead of setContent and that finally got sending emails with attachments to work on GAE.

No comments:

Post a Comment