Forums Register Login

Send PDF in JavaMail

+Pie Number of slices to send: Send
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)


Just before sending the message, the headers are:


Date:Fri, 15 Jul 2005 18:39:56 -0500 (CDT)
From onotreply@ptsteams.com
Reply-To onotreply@ptsteams.com
To:test@ptsteams.com
Subject:subject



Can anybody tell me what I've done wrong here?

I also noticed that the DataHandler has objectMimeType set to "multipart/mixed;
boundary="----=_Part_1_2073066384.1121471029718""

Can this be right? Is this the problem?
[ July 15, 2005: Message edited by: Dave Wingate ]
+Pie Number of slices to send: Send
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 )

+Pie Number of slices to send: Send
try apache commons email http://jakarta.apache.org/commons/email/

-Amit
+Pie Number of slices to send: Send
Hello all,

Has anyone worked on SearchTerm?

Rgds,

Seetesh
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
Great work Dave..
but still I want to know what is the advantage of the following Buffering code.


Regards
+Pie Number of slices to send: Send
I am trying to implement something similar to this. Does this work for xls files and doc files or does it mess the format.
+Pie Number of slices to send: Send
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 promise I will be the best, most loyal friend ever! All for this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 21583 times.
Similar Threads
AXIS attachments
Java Mail with Attachments
JavaMail installation
How To Send Multiple Attachments In An Email
how to send mail using gmail server
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:46:52.