Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Mail with Attachments  RSS feed

Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of a good tutorial discussing how to send JavaMail with attachments. Particularly, I'm trying to send an email with a pdf attachment. The PDF is an in-memory stream.

Also, do I need to worry about using MIMEUtility encoding methods? I don't really understand why I would have to "encode" my pdf stream or what character set I would have to encode it into. Does anyone know of a good explanation of this topic?

I've found some info on JGuru and have tried to use this code:

But this code is throwing a parse exception:

When run, I'm getting the following exception:

SMTPMailSender |javax.mail.internet.ParseException
at java.lang.Throwable.<init>(
at javax.mail.MessagingException.<init>(
at javax.mail.internet.ContentType.<init>(
at javax.mail.internet.MimeBodyPart.updateHeaders(
at javax.mail.internet.MimeBodyPart.updateHeaders(
at javax.mail.internet.MimeMultipart.updateHeaders(
at javax.mail.internet.MimeBodyPart.updateHeaders(
at javax.mail.internet.MimeMessage.updateHeaders(
at javax.mail.internet.MimeMessage.saveChanges(
at javax.mail.Transport.send(
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!