This discussion is archived
3 Replies Latest reply: Mar 22, 2013 11:43 PM by EJP RSS

Regarding PDF attachment in Mail

Madhav.T.Reddy Newbie
Currently Being Moderated
Hi ,

I have requirement like, Generate the XBRL file in to XHTML and convert it to PDF then send to mail as attachement as .pdf file.
I have done upto PDF generating but i am sturck up to send a mail as attachement.
main thing is i am not stored in local,if i do store local the i can manage it but i a not suppose to store in local.

my code look like
  DocumentBuilder builder;
 
                    try {
                        builder = dbf.newDocumentBuilder();
                    } catch (ParserConfigurationException e) {
                        return returnMsg;
                    }
                    //builder.setEntityResolver(new CatalogResolver());
                    Document doc;
 
 
                    try {
                        doc = builder.parse(new ByteArrayInputStream(newHTML.toByteArray()));
                    } catch (SAXException e) {
                        return returnMsg;
                    }
                    ITextRenderer renderer = new ITextRenderer();           
                    renderer.setDocument(doc, null);
                     outputfile = <<myfile name>>;
                     os= new FileOutputStream(outputfile);
                     renderer.layout();
                    renderer.createPDF(os);
} 
This code will store in local with specified name.
after this i need sendthe mail as attachement in fly with <<name>.pdf file

i can able send the mail attahement if the file stored in local.

I am using mail.jar and activation.jar files for email functionality.
Could any body help out me on this ?

Thanks,
Madhava

Edited by: EJP on 23/03/2013 14:14: added {noformat}
{noformat} tags: please use them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • 1. Re: Regarding PDF attachment in Mail
    aksarben Journeyer
    Currently Being Moderated
    I'm confused by the question. Are you getting a run time error? If so, please post the entire error message & stack trace.

    Or are you just unsure you how to accomplish this? Or are you having problems with security permissions for the file? Or something else?
  • 2. Re: Regarding PDF attachment in Mail
    Madhav.T.Reddy Newbie
    Currently Being Moderated
    Hi Thanks for u'r reply.

    so far i am developed the code for email functionality to attache the local stored PDF files as atttache the mail.
    here i am struck up to attach the file in mail with out storing the the PDF in local directory.
    I am tried in some ways but the some exceptions are getting.since today is week end i am unable to upload those.

    Frankly saying the i am excepting the some code samples to read the PDF file after converting the XHTML to PDF.


    Thanks,
    Madhava
  • 3. Re: Regarding PDF attachment in Mail
    EJP Guru
    Currently Being Moderated
    the some exceptions are getting
    Moderator: You've already been asked to post the exception(s) here. Until you do that you are just wasting time repeating yourself. The thread will be locked unless you advance the discussion as requested.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points