Skip to main content
Inspiring
May 21, 2008
Question

Creating a PDF and e-mailing it using CF

  • May 21, 2008
  • 2 replies
  • 1162 views
I used a tutorial online to create a PDF with data from a form. The problem that I am having is I don't know how to take that PDF and send it through an e-mail to a recipient. Either the file processes and displays a PDF and sends me the e-mail of the form data (which it was set to do before) or one of the other ways I tried it, it sent me a link that I used (in the code below) to the blank PDF form.

1) How do I e-mail the filled form to a recipient without them seeing the completed form. I want it to go to a confirmation page afterwards (CFIF statement in the same page) and send the data and PDF in the same e-mail

2) How can I set this up to differentiate the file names of the sent forms? I don't want all of the forms to come to the recipient with the exact same file name.

The client is asking for this ASAP and I don't know what version of CF is running on the web server (it is the clients server)

Any and all suggestions are welcome!
Thanks,
Jeremiah
This topic has been closed for replies.

2 replies

Inspiring
May 22, 2008
Yes you have to save the file to the server. You can do that with cfdocument. Then you have to call it using the full path.

If you're efficient, you'll use variables for the filename, including the path.

This is different than uploading files. Google <cfdocument> and you'll get the correct page from the cfml reference manual. Look at all the attributes and see what they do.
Inspiring
May 21, 2008
you can create a pdf file with cfdocument.

you can mail it as a file attachment with cfmail and cfmailparam.
JTrueAuthor
Inspiring
May 22, 2008
Hi Dan,
Thanks for the pointer, I've got the page generating PDF's, how do I attach that PDF to the e-mail response? I don't know how to call the name of the generated PDF and attach it using <cfmailparam>. Do i have to save the file to the server and then call it using a path? We had another developer build us an upload set once that would send us files as attachments, I tried to incorporate that code, but it dealt with a directory on the server, and I don't know how to make that work.

Thanks,
Jeremiah
Inspiring
May 22, 2008
If you are using CF 8.0.1 you should be able to use the content attribute of cfmailparam to attach a cfdocument PDF variable to a mail message without having to save your PDF to the file system. See the 8.0.1 release notes page 7 for new features of cfmail.
http://www.adobe.com/support/documentation/en/coldfusion/801/cf801releasenotes.pdf