• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

How to send form by email using ASP?

* Don't know how to add more points with this question, I would like to give more than 500points with this thread...

Dear EE Experts,

We would like to ask on how to add codes on the attached script, that will send the form by email after user finished filling up the registration form.
Though the attached script is still have a pending issue, regarding its CAPTCHA (it's also open on the another thread).
The case would be like this:
User fill-up the form, submit it, then it will go to its result page, which is the Thank You page...
Then an email would be sent to the Admin (internal), saying that there's a new user that needs for Approval.
Then the information of the user would be added to the database (but this INSERT matter is already open, my other other open thread)...

How to send this form thru email first... then will open another thread for the Admin Panel, for Approval...

Thank you!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">

<meta name="GENERATOR" content="Mozilla/4.7 [en] (Win98; I) [Netscape]">

<title>..:: New User Registration ::..</title>
<style TYPE="text/css">
<!--
	a
 	{
  		color:#000080;
		font-family:verdana;
		text-decoration:none;
		font-size:12px
	}
	
	
	a:active
 	{
  		color:red;

	}

	a:hover
 	{
  		color:#FF0000;
		text-decoration:none;
		cursor:crosshair;
	}
		
	table
	{
		font-family:verdana;
	}
	
	.td
	{
		font-family:verdana;
		font-size:12px;
	}

	.b
	{
		font-color:#FF0000;
		font-family:verdana;
		font-size:12px;
	}		

-->
</STYLE>

<!--validation-->

<script language="JavaScript" type="text/javascript">
if(!String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/, '');
  };
}

function isEmail(string) {
  return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
}
function checkform ( form ) {
  // ** START **
  //  if (form.username.value.trim() == "") {
  //	alert( "Please enter your Username." );-->
  //	 form.username.focus();-->
  //  return false ;-->
  //}
  if (form.password.value.trim() == "") {
    alert( "Please enter your Password." );
    form.password.focus();
    return false ;
  }
  if (form.repassword.value.trim() == "") {
    alert( "Please retype your Password." );
    form.repassword.focus();
    return false ;
  }
  if (form.repassword.value.trim() != form.password.value.trim()) {
    alert( "Password didn't match. Please retype." );
    form.repassword.focus();
    return false ;
  }
  if (form.fname.value.trim() == "") {
    alert( "Please enter your name." );
    form.fname.focus();
    return false ;
  }
  if (form.lname.value.trim() == "") {
    alert( "Please enter your surname." );
    form.lname.focus();
    return false ;
  }
  if (form.company.value.trim() == "") {
    alert( "Please enter your company name." );
    form.company.focus();
    return false ;
  }
  if (form.address.value.trim() == "") {
    alert( "Please enter your address." );
    form.address.focus();
    return false ;
  }
  if (form.email.value.trim() == "") {
    alert( "Please enter your email address." );
    form.email.focus();
    return false ;
  }
  
  if (!isEmail(form.email.value.trim())) {
    alert("Please enter correct Email address");
	  form.email.focus();
	  return false;
  }

  if (form.telephone.value.trim() == "") {
    alert( "Please enter your Telephone#." );
    form.telephone.focus();
    return false ;
  }
  if (form.mobile.value.trim() == "") {
    alert( "Please enter your Mobile#." );
    form.mobile.focus();
    return false ;
  }
  //if (form.code.value.trim() == "") {
  //  alert( "Please retype the confirmation code." );
  //  form.code.focus();
  //  return false ;
  //}
//  if (form.remobile.value.trim() != form.mobile.value.trim()) {
//    alert( "Mobile didn't match. Please retype." );
//    form.remobile.focus();
//    return false ;
//  }
  
    // ** END **
    return true ; // allow submission
}
</script>

</head>

<%
' On Error Resume Next

' Classsic ASP pages created by Andre F Bruton
' E-mail: andre@bruton.co.za
' Date: 2008/01/19

recaptcha_challenge_field  = Request("recaptcha_challenge_field")
recaptcha_response_field   = Request("recaptcha_response_field")
recaptcha_private_key      = "6Lc73cgSAAAAAL3HAD81jkLhDpFobzlCPHGvvGVi"
recaptcha_public_key       = "6Lc73cgSAAAAAALT8Nge2rLyJsiQjWZqwspCc8wg"
'cTemp = recaptcha_confirm(recaptcha_private_key, recaptcha_challenge_field, recaptcha_response_field)
%>
<%

'else
cTemp = recaptcha_confirm(recaptcha_private_key, recaptcha_challenge_field, recaptcha_response_field)
If cTemp <> "" Then 
if request.Form("Pass") = "Form" then
response.Write"<br />The error was <strong>"&cTemp&"</strong>"
end if
%>

<body bgproperties="fixed" bgcolor="#000000" onLoad="javascript:startmenu()">

<table width="760" border="0" cellspacing="3" cellpadding="1">
  <tr>
    <td width="134"><img src="../IMG/logo_res.jpg" alt="STIEBEL ELTRON" /></td>
    <td width="620" valign="top" bgcolor="#666666"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="548" height="197">
      <param name="movie" value="homeintro20.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <embed src="homeintro20.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="548" height="197"></embed>
    </object></td>
    <td width="134" bgcolor="#FFFFFF"><img src="../IMG/white_square.png" alt="ASIA" border="0" align="top"/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right" bgcolor="#999999"><font face="Verdana, Geneva, sans-serif" color="#ffffff">
		&nbsp;
	</td>
    <td bgcolor="#666666" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left" bordercolor="#999999" bgcolor="#000000"><img src="../IMG/member.jpg" width="548" /><br></td>
    <td bgcolor="#999999" valign="top" align="center" rowspan=13>&nbsp;
		
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    	<form action="" method="post">
			<% Else %>
    	<form name="form" id="form" method="post" action="signup_result1.asp" onSubmit="return checkform(this)"><%end if%>
		<input type="hidden" name="Pass" value="Form" />
    	<table width="100%" border="1" bordercolor="#ffffff" cellpadding="0" bgcolor="#999999">
    		<tr>
        		<td class="td" width="23%" align="right">First Name:</td>
           		<td width="77%"><input id="fname" name="fname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="23%" align="right">Last Name:</td>
           		<td width="77%"><input id="lname" name="lname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
           	<tr>
        		<td class="td" width="23%" align="right">Email:</td>
           		<td width="77%"><input id="email" name="email" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
            	</td>
        	</tr>
	   		<tr>
        		<td class="td" width="23%" align="right">Password:</td>
           		<td width="77%"><input id="password" name="password" type="password" size="25" maxlength="15" />&nbsp;<b><font class=
                "b">*</font></b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="23%" align="right">Re-type Password:</td>
           		<td width="77%"><input id="repassword" name="repassword" type="password" size="25" maxlength="15" />&nbsp;<b><font class="b">*</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="23%" align="right">Country:</td>
           		<td width="77%"><input id="country" name="country" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
         	   </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="23%" align="right">Telephone:</td>
        	   	<td width="77%"><input id="telephone" name="telephone" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">
                *</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="23%" align="right">Mobile:</td>
           		<td width="77%"><input id="mobile" name="mobile" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
	    	<tr>
    	    	<td class="td" width="23%" align="right">Company:</td>
        	   	<td width="77%"><input id="company" name="company" type="text" size="50" maxlength="25" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
    		<tr valign="top">
        		<td class="td" width="23%" align="right">Address:</td>
           		<td width="77%"><textarea name="address" id="address" rows="4" cols="39"></textarea>&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="23%" align="right">Confirm code:&nbsp;
				</td> 
           		<td width="77%">
					<%=recaptcha_challenge_writer(recaptcha_public_key)%>
                </td>
        	</tr>
	        <tr>
        		<td class="td" width="23%" align="right">&nbsp;</td>
           		<td width="77%"><input name="Submit" type="submit" value="SUBMIT FORM" onclick="checkform();" />&nbsp;
            		<input name="Reset" type="reset" value="RESET FORM" onClick="return confirm('Are you sure you want to reset the 
                    form?')" />
                </td>
        	</tr>
			<%
			if not IsEmpty(Request.Form("Submit")) then
			Response.Write("<tr><td colspan=""2"" align=""center"">")
			if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then
			Response.Write("<b style=""color:#00CC33"">The code you enter verified.</b>")
			else
			Response.Write("<b style=""color:#FF0000"">You entered the wrong code.</b>")
			end if
			Response.Write("</td></tr>" & vbCrLf)
			end if
			%>
			
            <!--#include file="reCaptcha.asp"-->

        </form>
        
        <!--javascript-->
        <script language="JavaScript" type="text/javascript">
		//If our user enters data in the username input, then we need to enable our button
		function OnChangedUsername()
		{
		if(document.form.username.value == "")
		{
		document.form.btnCheckAvailability.disabled = true;
		}
		else
		{
		document.form.btnCheckAvailability.disabled = false;
		}
		}
		function OnCheckAvailability()
		{
		if(window.XMLHttpRequest)
		{
		oRequest = new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}

		oRequest.open("POST", "AJAX.asp", true);
		oRequest.onreadystatechange = UpdateCheckAvailability;
		oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oRequest.send("strCmd=availability&strUsername=" + document.form.username.value);
		}
		function UpdateCheckAvailability()
		{
		if(oRequest.readyState == 4)
		{ 
		if(oRequest.status == 200)
		{
		document.getElementById("Available").innerHTML = oRequest.responseText;
		}
		else
		{
		document.getElementById("Available").innerHTML = "Asychronous Error";
		}
		}
		}
		</script>
        <!--END-->
    </table>
    </td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td align="center" bgcolor="#ffffff">
    	<a href = "javascript:history.back()"><font size="0.5e">BACK</font></a>
    </td>
  </tr>
</table>

</body>
</html>

Open in new window

0
Stiebel Eltron
Asked:
Stiebel Eltron
  • 5
  • 4
1 Solution
 
Wayne BarronCommented:
Visit the following link.
There you will find the script that is needed to send email from form.
http://www.powerasp.com/content/new/sending_email_cdosys.asp
I personally use #3

Carrzkiss
0
 
Stiebel EltronAuthor Commented:
@carrzkiss: So for this method, specially for method #3, would this require any installation on the server (local &/or host server such as godaddy.com)?
Because at this moment, we're testing everything locally, then later on will upload it @ our host server (godaddy.com)
0
 
Stiebel EltronAuthor Commented:
Additional, where should I insert it? @Registration form, right? Which part?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Wayne BarronCommented:
This will work with GoDaddy, and all other hosting companies.
This SHOULD work in an example, just change the mail server and your email and password in the top part of the mail.asp page.


mailform.asp
<form method="post" action="mail.asp">
<input type="text" name="name" />
<input type="text" name="email" />
<input type="text" name="subject" />
<textarea name="message" rows="5" cols="60"></textarea>
<input type="submit" name="submit" value="Send Mail" />
</form>

Open in new window


mail.asp
<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 
     
'This section provides the configuration information for the remote SMTP server.
     
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yourserver.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
     
ObjSendMail.Configuration.Fields.Update
     
'End remote SMTP server configuration section==

' gets the variables from the form to use in your mail
getName = request.form("name")
getEmail = request.form("email")
getSubject = request.form("subject")
getMessage = request.form("message")
     
ObjSendMail.To = "someone@someone.net" ' Put in the email address that you want to send the message to.
ObjSendMail.Subject = getSubject
ObjSendMail.From = getEmail &"("&getName&")"
     
'Now we are sending the email body
ObjSendMail.HTMLBody = "This is the first line of your email<br />"
ObjSendMail.HTMLBody = ObjSendMail.HTMLBody &"This is the second line of your email<br />"
' Now to add your variables to your email body
ObjSendMail.HTMLBody = ObjSendMail.HTMLBody &"Message from: "&getName&"<br /> with email: "&getEmail&"<br /> with subject: "&getSubject&"<br /> With Message: <br />"&getMessage&""
'ObjSendMail.TextBody = "this is the body"

' Now time to send the message.     
ObjSendMail.Send
     
Set ObjSendMail = Nothing 
%>

Open in new window


Good Luck
Carrzkiss
0
 
Wayne BarronCommented:
Just posted this same project code to my Coding Source site as well.
http://www.cffcs.com/Main.asp?Entry=26

Have a good one.
Carrzkiss
0
 
Stiebel EltronAuthor Commented:
I'll get back to you on Monday, asap... :-)
0
 
Wayne BarronCommented:
Sounds good.
Have a good weekend.

Carrzkiss
0
 
Stiebel EltronAuthor Commented:
Same to you!
:-)
0
 
Stiebel EltronAuthor Commented:
Great! If have any questions, I'll just open a new thread for you to earn more points!
Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now