By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

cdosys works but sends me two emails and doesn't want to redicect

P: 4
Hi there, I'm trying to get my cdosys code to work for email purposes. I am a newbie to all of this so any help will be appreciated. I have two questions:
Firstly my submit form goes directly to the thank_u.htm page when someone clicks on the link to go to my submit form.
Secondly if I take the response.redirect line out of my code, I get an empty email when someone opens the page and then the second one when the person clicks on the submit button. (The second email works fine.)
I think the answer for 1 should solve 2 as well.
Here is my code.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Submit Query</title>
  4. <link rel="stylesheet" type="text/css" href="../css/submit.css">
  5. </head>
  6. <h1>QUOTE FORM</h1>
  7. <body>
  8.  
  9.     <form name="feedback" method="post" action="submit.asp">
  10.         <label for="user">Your Name:</label>
  11.         <input type="text" name="txtName" ><br>
  12.  
  13.         <label for="user">The Name of your Business:</label>    
  14.         <textarea name="txtBusiness" id="newsize" ></textarea><br>
  15.  
  16.         <label for="user">Your Email Address:</label>    
  17.         <input type="text" name="txtEmail" class="text"><br>
  18.  
  19.         <label for="user">Your Cellphone number:</label>       
  20.         <input type="text" name="txtCell" ><br>
  21.  
  22.  
  23.         <label for="user">Registered with us: [y/n]</label>
  24.         <input type="text" name="txtRegistered" ><br>
  25.  
  26.         <label for="user">Your Quote:</label>    
  27.         <textarea name="txtQuote" class="input"></textarea><br>
  28.  
  29.  
  30. <a href="#"><input type="submit" class="submit" value="Submit"></a>
  31.  
  32.     </form>
  33.  
  34. </body>
  35.  
  36.  
  37.  
  38. </html>
  39.  
  40.  
  41. <%
  42.  
  43.  
  44. Dim HTMLBody
  45.  
  46. HTMLBody = HTMLBody & Replace(Request.Form("Contact_"), vbCrLf, "<br />") & "<br>" & "<br>"
  47. HTMLBody = HTMLBody & "<strong>" & "Your Name : " & "</strong>" & Request.Form("txtName") & "<br>"
  48. HTMLBody = HTMLBody & "<strong>" & " The Name of your Business : " & "</strong>" & Request.Form("txtBusiness") & "<br>"
  49. HTMLBody = HTMLBody & "<strong>" & "Your Email address : " & "</strong>" & Request.Form("txtEmail") & "<br>"
  50. HTMLBody = HTMLBody & "<strong>" & "Your Cellphone Number : " & "</strong>" & Request.Form("txtCell") & "<br>"
  51. HTMLBody = HTMLBody & "<strong>" & "Registered with us [y/n] : " & "</strong>" & Request.Form("txtRegistered") & "<br>"
  52. HTMLBody = HTMLBody & "<strong>" & "Your Quote : " & "</strong>" & Request.Form("txtQuote") & "<br>"
  53.  
  54.  
  55.  
  56. 'Create the e-mail server object 
  57. Set objCDOSYSMail = Server.CreateObject("CDO.Message") 
  58. Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration") 
  59. 'Outgoing SMTP server 
  60. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 
  61. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
  62. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
  63. objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
  64. objCDOSYSCon.Fields.Update 'Update the CDOSYS Configuration 
  65. Set objCDOSYSMail.Configuration = objCDOSYSCon 
  66. objCDOSYSMail.From = "**.*****.co.za    "
  67. objCDOSYSMail.To = "**@*****.co.za" 
  68. objCDOSYSMail.Subject = "Test"
  69. objCDOSYSMail.HTMLBody = htmlBody
  70. objCDOSYSMail.Send 
  71. 'Close the server mail object 
  72. Set objCDOSYSMail = Nothing 
  73. Set objCDOSYSCon = Nothing 
  74.  
  75. %>
Feb 20 '12 #1
Share this Question
Share on Google+
4 Replies


P: 4
Does anyone have any pointers or suggestions?
Mar 1 '12 #2

jhardman
Expert 2.5K+
P: 3,405
sending emails from asp code is one of the most frustrating things I have ever tried. Often your host will lock it down even though there is no issue in your code. Have you tried talking to your web host? They might have documentation available.

Jared
Mar 1 '12 #3

P: 4
hi jhardman

After trying lots of different code I asked my web host and they actually gave me this one. With instructions for the settings that I needed to change. I checked to see if I missed anything but I haven't.
Mar 5 '12 #4

P: 4
I thought that maybe the problem is with the html code but that doesn't really make sense to me. Thanks for your initial reply.
Mar 5 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.