ASP Email Form Sending but Content Not Being Sent

Reply

Join Date: Jun 2009
Posts: 1
Reputation: KelseyLeah is an unknown quantity at this point 
Solved Threads: 0
KelseyLeah KelseyLeah is offline Offline
Newbie Poster

ASP Email Form Sending but Content Not Being Sent

 
0
  #1
Jun 19th, 2009
Hi. I'm pretty new to the ASP part of the web developement world and need some help.

I built an ASP form that sends and works pretty musch exactly liek I want it to. The problem is that when the results of the form are emailed, you recieve a blank email. I should be receiving an email with the senders name, email, and comments. My hosting company thinks that there is something missing from that code that would make that information send or that the page that the code is .htm when it should be .asp. Could someone help me figure out whats wrong with my code so the information thats trying to be sent is actually getting sent?

Here is the code for my form (I have this in both .htm and .asp):
  1. <form name="Testing" method="post" action="ASPEmail_confirm.asp">
  2. <table cellpadding="2" cellspacing="2">
  3. <tr>
  4. <td height="40" colspan="2" bgcolor="white">ASPEmail - Contact Form</td>
  5. </tr>
  6. <tr>
  7. <td>Your Name:</td>
  8. <td><input name="VisitorName" type="text" size="46" /></td>
  9. </tr>
  10. <tr>
  11. <td>Your Email:</td>
  12. <td><input name="VistorEmail" type="text" size="46" /></td>
  13. </tr>
  14. <tr>
  15. <td valign="top">Your Message:</td>
  16. <td><textarea name="VistorComments" cols="35" rows="10"></textarea></td>
  17. </tr>
  18. <tr>
  19. <td>&nbsp;</td>
  20. <td align="right"><input type="submit" name="Submit" value="Submit" /></td>
  21. </tr>
  22. </table>
  23.  
  24. </form>

this is the code for the .asp page:
  1. <%
  2.  
  3. DIM strVName, strVEMail, strVComments
  4. strVName = request.form("VisitorName")
  5. strVEMail = request.form("VisitorEMail")
  6. strVComments = request.form("VisitorComments")
  7.  
  8. %> <%
  9. DIM Mail, strMsgHeader
  10. Set Mail = Server.CreateObject("Persits.MailSender")
  11. Mail.Host = "mail.example.com"
  12. Mail.Username = "example@example.com"
  13. Mail.Password = "xxxxx"
  14. Mail.From = strVEMail
  15. Mail.FromName = strVName
  16. Mail.AddAddress "example@example.net"
  17. Mail.AddReplyTo strVEMail
  18. Mail.Subject = "Email From Your Website"
  19. Mail.Body = strVComments
  20. %>
  21. <%
  22. On Error Resume Next
  23. Mail.Send
  24. Set Mail = Nothing
  25. IF Err <> 0 THEN
  26. Response.Write "There has been an error and your message could not be sent at this time using this form. Please contact us directly at (xxx)xxx-xxxx. " & Err.Description
  27. END IF
  28. %>

Thank you so much.
Last edited by Ezzaral; Jun 19th, 2009 at 6:02 pm. Reason: Snipped personal info from code.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 2
Reputation: nukedfood is an unknown quantity at this point 
Solved Threads: 0
nukedfood nukedfood is offline Offline
Newbie Poster

Re: ASP Email Form Sending but Content Not Being Sent

 
0
  #2
Jun 22nd, 2009
Not sure what is wrong with your code but thought I could suggest a code to you which I use. Grabs all the information fine everytime:

  1. If Request.Form.Count > 0 Then
  2. Const cdoSendUsingMethod = _
  3. "http://schemas.microsoft.com/cdo/configuration/sendusing"
  4. Const cdoSendUsingPort = 1
  5. Const cdoSMTPServer = _
  6. "http://schemas.microsoft.com/cdo/configuration/smtpserver"
  7. Const cdoSMTPServerPort = _
  8. "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
  9. Const cdoSMTPConnectionTimeout = _
  10. "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
  11. Const cdoSMTPAuthenticate = _
  12. "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
  13. Const cdoBasic = 1
  14. Const cdoSendUserName = _
  15. "http://schemas.microsoft.com/cdo/configuration/sendusername"
  16. Const cdoSendPassword = _
  17. "http://schemas.microsoft.com/cdo/configuration/sendpassword"
  18.  
  19. Dim objConfig ' As CDO.Configuration
  20. Dim objMessage ' As CDO.Message
  21. Dim Fields ' As ADODB.Fields
  22. Dim title, firstname, surname, email, confirmemail, reason, other, enquiry
  23.  
  24. title = Request.Form("title")
  25. firstname = Request.Form("firstname")
  26. surname = Request.Form("surname")
  27. email = Request.Form("email")
  28. confirmemail = Request.Form("confirmemail")
  29. reason = Request.Form("reason")
  30. other = Request.Form("other")
  31. enquiry = Request.Form("enquiry")
  32.  
  33. ' Get a handle on the config object and it's fields
  34. Set objConfig = Server.CreateObject("CDO.Configuration")
  35. Set Fields = objConfig.Fields
  36.  
  37. ' Set config fields we care about
  38. With Fields
  39. .Item(cdoSendUsingMethod) = cdoSendUsingPort
  40. .Item(cdoSMTPServer) = "smtp.yoursite.co.uk"
  41. .Item(cdoSMTPServerPort) = 25
  42. .Item(cdoSMTPConnectionTimeout) = 10
  43. .Item(cdoSMTPAuthenticate) = cdoBasic
  44. .Item(cdoSendUserName) = "you@yoursite.co.uk"
  45. .Item(cdoSendPassword) = "password"
  46.  
  47. .Update
  48. End With
  49.  
  50. Set objMessage = Server.CreateObject("CDO.Message")
  51.  
  52. Set objMessage.Configuration = objConfig
  53.  
  54. With objMessage
  55. .To = "whatever@where.com"
  56. .From = "whoever@where.co.uk"
  57. .Subject = "Customer Enquiry"
  58. .TextBody = "SMTP Relay Test Sent @ " & Now() & vbCrLf & "title: " & title & vbCrLf & "firstname: " & firstname & vbCrLf & "surname: " & surname & vbCrLf & "email: " & email & vbCrLf & "confirmemail: " & confirmemail & vbCrLf & "reason: " & reason & vbCrLf & "other: " & other & vbCrLf & "enquiry: " & enquiry
  59. .Send
  60.  
  61. End With
  62.  
  63. Set Fields = Nothing
  64. Set objMessage = Nothing
  65. Set objConfig = Nothing
  66. End If
  67. %>

I know it's not a solution but it's been useful for me!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 36
Reputation: tomer1 is an unknown quantity at this point 
Solved Threads: 1
tomer1 tomer1 is offline Offline
Light Poster

Re: ASP Email Form Sending but Content Not Being Sent

 
0
  #3
Jul 16th, 2009
please post your code error.

try to use this code:

  1. sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
  2. smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"
  3.  
  4. ' Set the mail server configuration
  5. Set objConfig=CreateObject("CDO.Configuration")
  6. objConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort
  7. objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
  8. objConfig.Fields.Update
  9.  
  10. ' Create and send the mail
  11. Set objMail=CreateObject("CDO.Message")
  12. ' Use the config object created above
  13. Set objMail.Configuration=objConfig
  14.  
  15. objMail.Subject="Subject"
  16. objMail.From="YourEmail@email.com"
  17. objMail.To="Email"
  18. objMail.HTMLBody= "Text"
  19. objMail.Send
Last edited by peter_budo; Jul 17th, 2009 at 2:13 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC