Conundrum 1 #1 October 25, 2007 I know how to write the code to make a contact form with input fields, what I don't know how to do is work with ASP and get the info sent to me when a client clicks "submit". Anyone who can help, please PM me. Thanks in advance. Quote Share this post Link to post Share on other sites tilley13k 0 #2 October 25, 2007 Say you've got a form like so: Subject: From: Body: Then create an ASP file called 'email.asp' (or whatever your action is called in your form) like so: <% Set mail = Server.CreateObject("CDO.Message") mail.To = 'email address destination' mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") mail.Send() Response.Write("Mail Sent!") Set mail = nothing %> This will give you a basic text email. Try looking up some tutorials for ASP Mail. That will also give you some help. Quote Share this post Link to post Share on other sites Conundrum 1 #3 October 25, 2007 So I would create the "e-mail.asp" example you gave and upload it to my FTP server? It would then send the info people type to me? Quote Share this post Link to post Share on other sites tilley13k 0 #4 October 25, 2007 Yes. Just make sure the ASP file name is the same as what action you're calling in the form. And depending on what kind of fields you have in your form, you'll have to include those in your ASP code depending on what you want your email to print. Quote Share this post Link to post Share on other sites Conundrum 1 #5 October 25, 2007 I'm lost. Quote Share this post Link to post Share on other sites tilley13k 0 #6 October 25, 2007 Try going to w3schools or something for a tutorial. They can do a lot better job describing things. http://www.w3schools.com/asp/asp_send_email.asp Quote Share this post Link to post Share on other sites PhreeZone 15 #7 October 25, 2007 Its easy. Fields have to match between the form and the ASP or they will not be transmitted. The ASP file needs to be named something like xyz.asp, in the Action= area you need to put in Action=xyz.asp".Yesterday is history And tomorrow is a mystery Parachutemanuals.com Quote Share this post Link to post Share on other sites punkd 0 #8 October 25, 2007 Quote I'm lost. I'll see if I can explain it a bit more. Ok so say your basic "form" page asks a few questions.. (lets call this page form.htm for arguments sake) example SUBJECT FROM BODY hence the code below... "form.htm" Subject: From: Body: So that will make a basic page with input fields for the visitor to fill in those 3 things. You can change those fields to what ever you want. Now pay attention to this line this tells the "form.htm" page what to do once the user presses the 'submit' button. It will look for the "email.asp" page. Now lets talk a bit more about the "email.asp" page Set mail = Server.CreateObject("CDO.Message") mail.To = 'email address destination' mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") mail.Send() Response.Write("Mail Sent!") Set mail = nothing %> There is a couple lines here to pay attention too. mail.To = 'email address destination' Insert your email address there. Make sure these 3 lines match what you have on your "form.htm" page.. remember the 3 input fields that were created SUBJECT FROM BODY make sure they match what is in the (" ") below. example if you named something "Subject" above make sure it matches up as ("Subject") below.. mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") hope this helps.. Thanks to tilley13k for the above code, saved me having to type it all again. Quote Share this post Link to post Share on other sites punkd 0 #9 October 26, 2007 Heres the code commented and broken down to explain it better... Subject: From: Body: Now we will look at email.asp and what its doing. <% 'This is starting a block of asp code Set mail = Server.CreateObject("CDO.Message") 'Creating an object that enables you to send a msg calling it "mail" mail.To = '[email protected]' ' Telling the variable who to send the message too mail.From = Request.Form("From") 'Retrieving the information from the previous forms "from" field and storing it mail.Subject = Request.Form("Subject") 'Retrieving the information from the previous forms "subject" field and storing it mail.TextBody = Request.Form("Body") 'Retrieving the information from the previous forms "body" field and storing it mail.Send() 'Sending all the information collected above to the email address Response.Write("Mail Sent!") 'This will tell the user that the mail has been sent, you can add some html code here if you look up how Set mail = nothing 'Resetting the variable to null %> ' This is closing off the block of asp code This is in laymans terms and not exactly what the code is doing, but its explained like that to make it easy to understand. Quote Share this post Link to post Share on other sites Conundrum 1 #10 October 26, 2007 Maybe I'm not doing it correctly. Is your example exactly what I should use as the code (filling in what e-mail the info goes to)? If I want the info to go to [email protected], can you give me the exact code I would need to make it work? Quote Share this post Link to post Share on other sites punkd 0 #11 October 26, 2007 Call this page "email.asp" and upload it to the same directory as where ever your "form" page is. <% Set mail = Server.CreateObject("CDO.Message") mail.To = "[email protected]" mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") mail.MailFormat = 0 mail.BodyFormat = 0 mail.Send() Response.Write("Mail Sent!") Set mail = nothing %> THIS IS ASSUMING, that what ever your form page is has some input's named From, Subject and Body Example you should see something similar to these 3 lines (what matters is the part thats in bold) name="Subject"/> name="From"/> name="Body" rows="5" cols="20"> If you still don't understand, post the code to your forms page, or pm me it. edit to add: the form page must also contain this line Quote Share this post Link to post Share on other sites Conundrum 1 #12 October 26, 2007 Thanks everyone for the help. I have it figured out (for now). I'm sure I'll still have questions about certain things. And if I do, I know where to come! Quote Share this post Link to post Share on other sites Mr17Hz 1 #13 October 26, 2007 If you have any control over the architecture of the general site, I strongly suggest checking out DotNetNuke, www.DotNetNuke.com, which provides a content management system with a whole slew of modules already available that are likely to solve your problem without writing any code. Specifically, you can set up a page using the User Tables module that will allow them to enter information and will send you the results.Matt Christenson [email protected] http://www.RealDropzone.com - A new breed of dropzone manifest software. Quote Share this post Link to post Share on other sites Join the conversation You can post now and register later. If you have an account, sign in now to post with your account. Note: Your post will require moderator approval before it will be visible. Reply to this topic... × Pasted as rich text. Paste as plain text instead Only 75 emoji are allowed. × Your link has been automatically embedded. Display as a link instead × Your previous content has been restored. Clear editor × You cannot paste images directly. Upload or insert images from URL. Insert image from URL × Desktop Tablet Phone Submit Reply 0
tilley13k 0 #2 October 25, 2007 Say you've got a form like so: Subject: From: Body: Then create an ASP file called 'email.asp' (or whatever your action is called in your form) like so: <% Set mail = Server.CreateObject("CDO.Message") mail.To = 'email address destination' mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") mail.Send() Response.Write("Mail Sent!") Set mail = nothing %> This will give you a basic text email. Try looking up some tutorials for ASP Mail. That will also give you some help. Quote Share this post Link to post Share on other sites
Conundrum 1 #3 October 25, 2007 So I would create the "e-mail.asp" example you gave and upload it to my FTP server? It would then send the info people type to me? Quote Share this post Link to post Share on other sites
tilley13k 0 #4 October 25, 2007 Yes. Just make sure the ASP file name is the same as what action you're calling in the form. And depending on what kind of fields you have in your form, you'll have to include those in your ASP code depending on what you want your email to print. Quote Share this post Link to post Share on other sites
tilley13k 0 #6 October 25, 2007 Try going to w3schools or something for a tutorial. They can do a lot better job describing things. http://www.w3schools.com/asp/asp_send_email.asp Quote Share this post Link to post Share on other sites
PhreeZone 15 #7 October 25, 2007 Its easy. Fields have to match between the form and the ASP or they will not be transmitted. The ASP file needs to be named something like xyz.asp, in the Action= area you need to put in Action=xyz.asp".Yesterday is history And tomorrow is a mystery Parachutemanuals.com Quote Share this post Link to post Share on other sites
punkd 0 #8 October 25, 2007 Quote I'm lost. I'll see if I can explain it a bit more. Ok so say your basic "form" page asks a few questions.. (lets call this page form.htm for arguments sake) example SUBJECT FROM BODY hence the code below... "form.htm" Subject: From: Body: So that will make a basic page with input fields for the visitor to fill in those 3 things. You can change those fields to what ever you want. Now pay attention to this line this tells the "form.htm" page what to do once the user presses the 'submit' button. It will look for the "email.asp" page. Now lets talk a bit more about the "email.asp" page Set mail = Server.CreateObject("CDO.Message") mail.To = 'email address destination' mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") mail.Send() Response.Write("Mail Sent!") Set mail = nothing %> There is a couple lines here to pay attention too. mail.To = 'email address destination' Insert your email address there. Make sure these 3 lines match what you have on your "form.htm" page.. remember the 3 input fields that were created SUBJECT FROM BODY make sure they match what is in the (" ") below. example if you named something "Subject" above make sure it matches up as ("Subject") below.. mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") hope this helps.. Thanks to tilley13k for the above code, saved me having to type it all again. Quote Share this post Link to post Share on other sites
punkd 0 #9 October 26, 2007 Heres the code commented and broken down to explain it better... Subject: From: Body: Now we will look at email.asp and what its doing. <% 'This is starting a block of asp code Set mail = Server.CreateObject("CDO.Message") 'Creating an object that enables you to send a msg calling it "mail" mail.To = '[email protected]' ' Telling the variable who to send the message too mail.From = Request.Form("From") 'Retrieving the information from the previous forms "from" field and storing it mail.Subject = Request.Form("Subject") 'Retrieving the information from the previous forms "subject" field and storing it mail.TextBody = Request.Form("Body") 'Retrieving the information from the previous forms "body" field and storing it mail.Send() 'Sending all the information collected above to the email address Response.Write("Mail Sent!") 'This will tell the user that the mail has been sent, you can add some html code here if you look up how Set mail = nothing 'Resetting the variable to null %> ' This is closing off the block of asp code This is in laymans terms and not exactly what the code is doing, but its explained like that to make it easy to understand. Quote Share this post Link to post Share on other sites
Conundrum 1 #10 October 26, 2007 Maybe I'm not doing it correctly. Is your example exactly what I should use as the code (filling in what e-mail the info goes to)? If I want the info to go to [email protected], can you give me the exact code I would need to make it work? Quote Share this post Link to post Share on other sites
punkd 0 #11 October 26, 2007 Call this page "email.asp" and upload it to the same directory as where ever your "form" page is. <% Set mail = Server.CreateObject("CDO.Message") mail.To = "[email protected]" mail.From = Request.Form("From") mail.Subject = Request.Form("Subject") mail.TextBody = Request.Form("Body") mail.MailFormat = 0 mail.BodyFormat = 0 mail.Send() Response.Write("Mail Sent!") Set mail = nothing %> THIS IS ASSUMING, that what ever your form page is has some input's named From, Subject and Body Example you should see something similar to these 3 lines (what matters is the part thats in bold) name="Subject"/> name="From"/> name="Body" rows="5" cols="20"> If you still don't understand, post the code to your forms page, or pm me it. edit to add: the form page must also contain this line Quote Share this post Link to post Share on other sites
Conundrum 1 #12 October 26, 2007 Thanks everyone for the help. I have it figured out (for now). I'm sure I'll still have questions about certain things. And if I do, I know where to come! Quote Share this post Link to post Share on other sites
Mr17Hz 1 #13 October 26, 2007 If you have any control over the architecture of the general site, I strongly suggest checking out DotNetNuke, www.DotNetNuke.com, which provides a content management system with a whole slew of modules already available that are likely to solve your problem without writing any code. Specifically, you can set up a page using the User Tables module that will allow them to enter information and will send you the results.Matt Christenson [email protected] http://www.RealDropzone.com - A new breed of dropzone manifest software. Quote Share this post Link to post Share on other sites