#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0

    Need help with form


    I try doing to modify/build a form with cdosys, but it cant seems to send. And I cant figure how to add drop-down list & checkbox?

    I'm still new to writing asp. Anyone can help? Thanks.

    the form code -

    Code:
    <%@ LANGUAGE="VBSCRIPT" %>
    <% option explicit %>
    <% Response.Buffer = True %>
    
    
    <%
    
    Dim smtpserver,youremail,yourpassword,ContactUs_Name,ContactUs_Email
    Dim ContactUs_Subject,ContactUs_Body,Action,IsError
    	
    smtpserver = "xxxxxxx"
    youremail = "xxxxx@xxx.com"
    yourpassword = "xxxxx"
    	
    ContactUs_Name = Request("ContactUs_Name")
    ContactUs_Email = Request("ContactUs_Email")
    ContactUs_Subject = Request("ContactUs_Subject")
    ContactUs_Body = Request("ContactUs_Body")
    Action = Request("Action")
    	
    
    %>
    
    <html>
    
    <head>
    <title>Contact Us </title>
    </head>
    
    <body>
    
    <%
    If Action = "SendEmail" Then
    	
    	
    	Dim strBody
    	
    	' Here we create a nice looking html body for the email
    	strBody = strBody & "<font face=""Arial"">Contact Us Form submitted at " & Now() &  vbCrLf & "<br><br>"
    	strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") &  vbCrLf & "<br>"
    	strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "<br>"
    	strBody = strBody & "Name" & " : " & " " & Replace(ContactUs_Name,vbCr,"<br>") & "<br>"
    	strBody = strBody & "Email" & " : " & " " & Replace(ContactUs_Email,vbCr,"<br>") & "<br>"
    	strBody = strBody & "Subject" & " : " & " " & Replace(ContactUs_Subject,vbCr,"<br>") & "<br>"
    	strBody = strBody & "<br>" & Replace(ContactUs_Body,vbCr,"<br>") & "<br>"
    	strBody = strBody & "</font>"
    	
    	Dim ObjSendMail
    	Set ObjSendMail = CreateObject("CDO.Message") 
         
         
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = 2 'Send the message using the network (SMTP over the network).
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = smtpserver
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = 25 
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = False 
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = 60
         
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = 1 'basic (clear-text) authentication
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = youremail
    	ObjSendMail.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = yourpassword
         
    	ObjSendMail.Configuration.Fields.Update
         
         
    	ObjSendMail.To = youremail
    	ObjSendMail.Subject = ContactUs_Subject
    	ObjSendMail.From = ContactUs_Email
         
    	ObjSendMail.HTMLBody = strBody
         
    	ObjSendMail.Send
         
    	Set ObjSendMail = Nothing 
    	
    %>
    
    
    <table border="0" cellpadding="3" cellspacing="3">
      <tr>
    
    
    <td valign="top">
    We'll get back to you very soon.
    
    
    </td>
    </tr>
    </table>
    <% Else %>
    
    <form action="form.asp" method="POST">
    <input type="hidden" name="Action" value="SendEmail">
    <font size="2">Contact Us:</font>
    <br><br>
    	<table border="0" cellspacing="1">
    		<tr>
    			<td valign="top">
    				Name:
    			</td>
    			<td colspan="2">
    				<input type="text" name="ContactUs_Name" size="35" value="<% =ContactUs_Name %>">
    			</td>
    		</tr>
    		<tr>
    			<td valign="top">
    				Email:
    			</td>
    			<td colspan="2">
    				<input type="text" name="ContactUs_Email" size="35" value="<% =ContactUs_Email %>">
    			</td>
    		</tr>
    		<tr>
    			<td valign="top">
    				Subject:
    			</td>
    			<td colspan="2">
    				<input type="text" name="ContactUs_Subject" value="<% =ContactUs_Subject %>" size="35">
    			</td>
    		</tr>
    		<tr>
    			<td valign="top">
    				Message:
    			</td>
    			<td valign="top">
    				<textarea rows="10" name="ContactUs_Body" cols="40"><% =ContactUs_Body %></textarea>
    			</td>
    		</tr>
                	<tr>
    			<td valign="top">&nbsp;
    				
    			</td>
    			<td colspan="2">
    				<input type="submit" value="Send Message">
    			</td>
    		</tr>
    	</table>
    </form>
    
    <% End If %>
    
    </body>
    
    </html>
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0
    the error is

    CDO.Message.1 error '80040220'

    The "SendUsing" configuration value is invalid.

    /form.asp, line 73
  4. #3
  5. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,436
    Rep Power
    4539
    I don't see where you're giving your smtp information to your cdo object, but I don't use cdo, it's a separate windows object not part of asp.

    There is cdo documentation somewhere on the microsoft website.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0
    Thanks a lot, I get u.

    Another thing is how do I add drop-down list & checkbox to this form in order to make it send in html format??

    Any advise?

IMN logo majestic logo threadwatch logo seochat tools logo