Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I generate an email attachment from a webpage-based form?

Status
Not open for further replies.

PPettit

IS-IT--Management
Sep 13, 2003
511
US
We've got some forms (mostly in PDF) that we use for various things. What we'd like to do is set up a webpage that will allow our employees to access a form, fill in any blanks, and then submit it via email by clicking on a button. We'd like the form to be sent as an attachment instead of just text in the body of the message.

This is what I have in mind:
I would need to create some kind of webpage to collect the data. When the user hit's the "Submit" button, that data would be written to a PDF file (or possibly a Word document). Once the file has been created it would be attached to an email message and sent to the intended recipient.

Can this be done? If not, what other ways can I go about this?

In case it helps to know, our website is hosted by another company. If I remember correctly, I have access to most of the common webserver technologies except for ASP. It would take some doing, but I can even do that if need be.
 
Once you've worked out which server-side scripting language to use, you can do some searching online and you'll find all the pieces to the puzzle - perhaps even a pre-written script, as this sort of thing has been done many times before.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
I think you need to carve the problem up into bite-size chunks:

1) Collect input from users via a form - this is easy and can be accomplished in any server-side language: perl, php, etc...

2) Generate a .pdf, .doc or whatever file from the collected data. This is more tricky, you're going to need more specialised software on the server to do that. I think I read that ColdFusion can generate pdf files out of the box, I don't know about others.

3) Once you've got your file, you need to attach it. That ought to be straightforward enough, dig around in the mail-sending commands/libraries of your chosen language.

Having said all that, it sounds like a bad idea to me. Why bloat a simple text communication by wrapping it in a bulky file format? People may also be nervous about opening the attachment anyway. If you need to prettify the output, consider sending an HTML email instead of plain text - it'll still be a lot lighter than a pdf.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
At this time, I don't really have an issue with the input form. Once I have the backend portion in place I figure I can work out the form issues from there. My main concern is just finding a backend solution to create some kind of email attachment and then send the message.

I've used a Perl script called "nms Formmail" that I found at I don't know much about Perl but I did get it working well enough to generate a simple HTML email message. The problem is that I need the form to come as an attachment, not as the body of the email. PDF is the desired attachment type. A MS Word document would be second.

I agree, this is kind of an odd way to do things but this is how our new Human Resources manager wants it to work.
 
PHP can be used to create pdf's. Here's one extension you could use:
Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Is the server UNIX or Windows?

If it is UNIX, you could possibly use the uuencode command in your server side code to send an attachment through sendmail/postfix or whatever mail program you have.

Regards,
Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top