Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a PDF and e-mailing it using CF

Explorer ,
May 21, 2008 May 21, 2008
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
TOPICS
Advanced techniques
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2008 May 21, 2008
you can create a pdf file with cfdocument.

you can mail it as a file attachment with cfmail and cfmailparam.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 22, 2008 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 22, 2008 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 23, 2008 May 23, 2008
Thanks to both of you for your suggestions. I was able to make the form generate a PDF and send it. The last question I have now is how to delete the resulting PDF. I looked at the PDF you linked and it makes sense, but looking at livedocs, I don't see a remove parameter in the cfmail and cfmailparam pages.

I don't know if the server I am hosting this on is using 8 or 7 so if someone could point me to the old way to do it, I would be most appreciative.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2008 May 24, 2008
you delete files with cffile tag.
since you are sending this file as attachment, you should set
spoolenable="no" in your cfmail tag so that your email is sent
immediately instead of going to the mail spool first - otherwise if you
delete the attached file your email will fail... or you won;t be able to
delete the file...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2008 May 24, 2008
LATEST
If you are using cf8 you can set remove="true" and it will delete the file after the mail is sent.

http://www.bennadel.com/index.cfm?dax=blog:1214.view

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2008 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources