This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Java Mail with Attachments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail with Attachments" Watch "Java Mail with Attachments" New topic
Author

Java Mail with Attachments

Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
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)


Fun programming etcetera!
 
 
subject: Java Mail with Attachments
 
Similar Threads
How To Send Multiple Attachments In An Email
Send PDF in JavaMail
Java mail attachement problem
How to send email with multiple attachments
Sending attachments with emails in Javamail