Skip to main content
nikos101
Inspiring
January 30, 2010
Answered

Send pdf in an email, without ever having to have saved the pdf on server

  • January 30, 2010
  • 2 replies
  • 1842 views

I know how to send files in emails in CF.

How could I modify the following code so that I could send the PDF in an email, without ever having to have saved the file on the server?

<!--- The compasstravel database is part of the Getting Started 
    tutorial application, found under the cfdocs directory. --->
<cfquery datasource="compasstravel" name="compasstrips">
SELECT tripName, tripDescription, tripLocation, price
FROM trips
ORDER BY price
</cfquery>
<cfdocument format="pdf"
        filename="#GetDirectoryFromPath(GetTemplatePath())#/compasstrips.pdf"
        overwrite="yes">
    <cfdocumentsection> 
        <h1 align="center">Compass Travel</h1>
        <h2 align="center">Destination Guide</h2>
        <p align="center"><img src="cfdocs/getting_started/photos/somewhere.jpg"></p>
    </cfdocumentsection> 
    <cfdocumentsection> 
        <cfdocumentitem type="header">
            <font size="-3"> <i>Compass Travel Trip Descriptions</i></font>
        </cfdocumentitem> 
        <cfdocumentitem type="footer"> 
            <font size="-3"> 
                <cfoutput>Page #cfdocument.currentpagenumber#</cfoutput>
            </font> 
        </cfdocumentitem> 
        <cfoutput query="compasstrips"> 
            <hr>
            <h2>#tripName#</h2>
            <p><b>#tripLocation#</b></p>
            <p>Price: #DollarFormat(price)#</p>
            <p>#tripDescription#</p>
        </cfoutput> 
    </cfdocumentsection> 
</cfdocument>
    This topic has been closed for replies.
    Correct answer BKBK

    I'm sure theres a way to create these files without saving, I can't remember the tutorial


    I'm sure theres a way to create these files without saving, I can't remember the tutorial

    Nice you should say that, Nikos101. I played with it some more, and found that you can indeed send the PDF as attachment without first saving it. I did it like this:

    <cfdocument format="PDF" name="test">
    test pdf content
    </cfdocument>

    <cfmail from="bkbk@adobe.com" to="bkbk@adobe.com" subject="pdf attachment test">
    <cfmailparam disposition="attachment" file="testDoc.pdf" type="application/pdf" content="#test#" >
    mail content: blah blah blah
    </cfmail>

    2 replies

    BKBK
    Community Expert
    Community Expert
    January 30, 2010

    I think you first have to save the PDF file to the server before you can send it as an attachment.

    Inspiring
    January 30, 2010

    I used to think the very same thing.


    BKBK
    Community Expert
    Community Expert
    January 30, 2010

    ... until...


    Inspiring
    January 30, 2010

    Probably the same answer you got on this thread.  http://forums.adobe.com/thread/565893?tstart=0