• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Mail with Attachments

 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>(Throwable.java)
at javax.mail.MessagingException.<init>(MessagingException.java:34)
at javax.mail.internet.ContentType.<init>(ContentType.java:72)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1016)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:790)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:216)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1841)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1822)
at javax.mail.Transport.send(Transport.java:80)
at ct.fw.mail.SMTPMailSender.run(SMTPMailSender.java:294)
at java.lang.Thread.run(Thread.java:802)
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic