I have little experience with javamail and would really appreciate any help you could offer on this error. I'm trying to send a pdf (in memory) as an attachment to an email.
So far I've got:
And this helper class:
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)
You have to write your implementation of DataSource so that it returns a new instance of the InputStream every time getInputStream() is called. You have to read it into a buffer in order to do this. Here's my implementation of InputStreamDataSource which I've tested (it works )
Brilliant. Buffering the inputstream worked for me as well. Thanks for your help. I've been beating my head against the monitor for quite a while on this one. [ October 10, 2005: Message edited by: Dave Wingate ]
Awais Bajwa
Ranch Hand
Joined: Jan 16, 2001
Posts: 190
posted
0
Great work Dave.. but still I want to know what is the advantage of the following Buffering code.
Regards
Revanth Sharma
Greenhorn
Joined: Jul 30, 2011
Posts: 14
posted
0
I am trying to implement something similar to this. Does this work for xls files and doc files or does it mess the format.
madhava Thamata
Greenhorn
Joined: Mar 24, 2013
Posts: 3
posted
0
Hi All
I have same requriement like to attache the PDF in mail with out saving in local.
could any body provide some info about my requirement.
Thanks,
Madhava.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.