HTML Form to CSV or XLS

I have an HTML form that records 50 or so fields.

When submitted, I would like the form to email a CSV file, or XLS file to a specific email address for import into another application.

My limitations are that I can only use Javascript, HTML or ASP...  no .NET or PHP...  The environment I'm working in will not support this...

Does anyone have any suggestions on how this could be completed?
Who is Participating?
b0lsc0ttConnect With a Mentor IT ManagerCommented:
The basics for just this part of the code are below in the snippet then.  I added a couple of notes.  One key thing is the file will be created or overwritten by the CreateTextFile line.  If you don't want to overwrite the file then you just want to make a small change to that line (true becomes false) and test to see if the file exists firsts (so you only run the code if the file DOESN'T exist).
Let me know how that helps or if you have a question.

Set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFS.CreateTextFile("c:\inetpub\wwwroot\filename.csv", true)
oFile.WriteLine ("Name,Phone,Email")
' code to get recordset results for the csv file's contents
'   the recordset object is called rs in my code below
'   fields are named as I have above in the "header row"
'   none of the field values or header stuff is in quotes right now ...
'     but that can be added if required
While NOT rs.EOF
    oFile.WriteLine (rs("Name") & "," & rs("Phone") & "," & rs("Email"))
Set oFile = Nothing
Set oFS = Nothing

Open in new window

b0lsc0ttIT ManagerCommented:
ASP can do it.  Provide details on the form like field names (i.e. the html).  Maybe do just a small form with 5 fields if you want detailed code.  You also need to find out what mail object you can use.  The server could have a few different ones.  Your web host provider or server admin should be able to provide that info (or at least the OS of the server).  The type of file to make will be a CSV file since an XLS file can't really be made just with ASP and the web server.  A 3rd party object is needed to create a real Excel file.
Keep in mind that the form info should be validated by the ASP code too.  You don't want to get invalid or even harmful info.  You will also want to take steps to prevent this ASP script from being abused by bots, etc that will "autosubmit" to it.
UGSnowAuthor Commented:
Thanks bol

Can you provide a quick code snippet on how to generate the CSV file?  CSV works best, I was just thinking XLS would be easier, but apparently not :)

Lets say that I have the following form fields:


but I only want Name, Phone and Email to be included in the CSV...  Is this something that can be done?   Server OS is Windows Server 2008.

No need to worry about bot useage at this point as this form will be available to authenticiated members only.  

Thanks so much for your help... Looking forward to a solution!
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

UGSnowAuthor Commented:
Thank you!
b0lsc0ttIT ManagerCommented:
I'm glad I could help.  Thanks for the grade, the points and the fun question.
I am trying to do the same things however I need to know what type of action I need to take with the ASP web page form.  Do I get or put?  Also the code you listed in this question, do I create a VBS file with that and put/get to it?

Thanks for the assistance.
b0lsc0ttIT ManagerCommented:
Have you opened your own question for this?  If not then please do.  Feel free to use the "ask a related question" link that is right above the box to type the comment you want to post here.  It will help you ask a new question but also alert all the participants of the original question of your new one.  If you have already opened a new question for this then please post its URL here in a comment.  I will be glad to look at it and try to help.

Don't forget to include details and a good title in your related question.  From what you said above I would also ask you clarify what you mean by get/put.  If you have a question about opening a new question then let me know.  I am glad this was helpful and hope I can also help you with your issue.

I did ope my question:

The Title is: Take ASP web page form data and create a CSV

Thanks for giving it a look.
b0lsc0ttIT ManagerCommented:
It looks like you already got your answer.  If not or I looked at the wrong question then let me know.  Otherwise glad to see you got the help you needed and that this could be some help too. :)

All Courses

From novice to tech pro — start learning today.