Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Problem with PDF reports as attachments
jsinai
We are having a strange problem: we generate BIRT reports and attach them to emails. If users download the reports to their desktop, and open them with a PDF viewer, all is well. However, if they click on them in an email client like a browser, they render as garbage characters. We are correctly setting the mime type in the email. Has anyone ever seen this behavior?
Thanks,
Julian
Find more posts tagged with
Comments
JasonW
Are you setting them as attachments?
Jason
jsinai
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81889" data-time="1314229434" data-date="24 August 2011 - 04:43 PM"><p>
Are you setting them as attachments?<br /></p></blockquote>
<br />
Jason, thanks for your reply. Yes, as far as I know we are doing it right:<br />
<br />
final Multipart multipart = new MimeMultipart(); // create a multi-part message<br />
multipart.addBodyPart(messageBodyPart); // set text message part<br />
<br />
messageBodyPart = new MimeBodyPart(); // part two is attachment<br />
final DataSource source = new FileDataSource(reportURL);<br />
messageBodyPart.setDataHandler(new DataHandler(source));<br />
messageBodyPart.setFileName(reportURL.substring(reportURL.lastIndexOf("/") + 1, reportURL.length()));<br />
multipart.addBodyPart(messageBodyPart);<br />
<br />
message.setContent(multipart); // send the complete message parts<br />
Transport.send(message);
JasonW
Is the report url a completed report, meaning a pdf on the file system?
Jason
jsinai
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81914" data-time="1314288168" data-date="25 August 2011 - 09:02 AM"><p>
Is the report url a completed report, meaning a pdf on the file system?<br />
<br />
Jason<br /></p></blockquote>
<br />
Jason, thanks for the reply. I solved the problem: a colleague realized that in a multipart message, the mime type of both the body and the attachments need to be set. I was only setting it for the pdf attachment. Once I set the body to text/plain, everything worked.<br />
<br />
Julian
JasonW
Glad to read. Just for info, if you use the engine api you can stream report output as an attachment as well. This would mean not writting the output to the file system.
Jason
jsinai
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81920" data-time="1314288910" data-date="25 August 2011 - 09:15 AM"><p>
Glad to read. Just for info, if you use the engine api you can stream report output as an attachment as well. This would mean not writting the output to the file system.<br />
<br />
Jason<br /></p></blockquote>
Thanks for the info, that would definitely be more efficient.<br />
<br />
Julian