Connecting Tech Pros Worldwide Help | Site Map

Asp form processing - send email

Newbie
 
Join Date: Apr 2009
Posts: 10
#1: Apr 28 '09
I want to send form data to email using ASP (post method). I am trying following script but it's not working.Please suggest. Also suggest how to redirect it after pressing submit button.
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. Dim name, phone,city, email, mail
  3.  
  4. name=Request.Form("name")
  5. phone=Request.Form("phone")
  6. city=Request.Form("city")
  7. email=Request.Form("email")
  8. Response.Write("Name: " & name & "<br />")
  9. Response.Write("Phone: " & phone & "<br />")
  10. Response.Write("City: " & city & "<br />")
  11. Response.Write("Email: " & email & "<br />")
  12.  
  13. Set myMail=CreateObject("CDO.Message")
  14. myMail.Subject="IIT paper"
  15. mail.To = "prabodhan17@gmail.com"
  16. mail.From = Request.Form("name")
  17. myMail.Send
  18. set myMail=nothing
  19. Response.Write("Mail Sent!")
  20.  
  21. %>
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Apr 30 '09

re: Asp form processing - send email


I've asked someone else to look into this question, since I always get frustrated with email scripts. The first question I have is, are you sure the form is coming through correctly? You can check with this simple code:
Expand|Select|Wrap|Line Numbers
  1. for each x in request.form
  2.    response.write x & ": " & request.form(x) & "<br>" & vbNewLine
  3. next
  4.  
To redirect, you just need to do this:
Expand|Select|Wrap|Line Numbers
  1. response.redirect "somePage.asp"
but it won't work if you have any response.write on the page, so don't try to add it until you have everything else straightened out, and you can delete or comment out all of those lines.

Let me know if this helps.

Jared
colinod's Avatar
Familiar Sight
 
Join Date: Nov 2007
Posts: 182
#3: Apr 30 '09

re: Asp form processing - send email


Hi

In the from name field on the form are you outting a name or an email address, if its a name only i think it has to be an email address.

Give that a try and let me know

Colin
Reply