Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 28th, 2003, 08:04 PM
Registered User
 
Join Date: Oct 2003
Location: Houston, TX, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting a Record and sending an email

I am new to asp. I need to insert a record and then send an email. Does any one have any suggestion on how to do this in asp.

Ambir Comparato
  #2 (permalink)  
Old October 29th, 2003, 07:01 AM
Friend of Wrox
Points: 422, Level: 7
Points: 422, Level: 7 Points: 422, Level: 7 Points: 422, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: La Jolla, CA, USA.
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your question is little vague regarding inserting a record.

What database Access, SQL?

Here is how you can send an email:

<%
'+
' Send email using CDO. Must be enabled in IISAdmin.
'-
Set SMTP = Server.CreateObject("CDONTS.NewMail")
SMTP.From = "fromaddress@domain.com"
SMTP.To = "recipient@domain.com"
SMTP.Subject = "Your subject here"
SMTP.Body = "This is the body of the message."
On Error Resume Next ' ignore errors
SMTP.Send
Set SMTP = Nothing
%>


  #3 (permalink)  
Old October 30th, 2003, 07:28 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

CHECK THIS CODE MORE USEFUL FOR YOU
'''''''''''''''''''PAGE NAME=contactus.asp'''''''''''''''
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<script language="JavaScript">
<!--
function onSubmit1()
{
if (document.form1.txtContactName.value=="")
{
    alert("Please Enter the Contact Name")
    document.form1.txtContactName.focus()
    return;
}
 if ((document.form1.txtEmail.value == "")&&(document.form1.txtFax.value == "")&&(document.form1.txtTel.value == ""))
  {
    alert("Please enter a value for E mail / Phone / Fax");
     document.form1.txtTel.focus();
    return;
  }



   if (document.form1.txtEmail.value!= "")
  {
 var mail1=document.form1.txtEmail.value;
  var i1 = mail1.indexOf('@');
   var i2 = mail1.lastIndexOf('@');
   var i3 = mail1.indexOf('.');
  if (mail1.length<=5)
  {
  alert("Your E-mail address is too small");
   document.form1.txtEmail.focus();
  return;
   }

    if(i1==-1)
 {
  alert(" E-mail address must have a '@' ");
   document.form1.txtEmail.focus();
 return;
  }

   if (i3+1==mail1.length)
  {
 alert(" E-mail address cannot contain '.' in end");
  document.form1.txtEmail.focus();
  return;
 }

  if(i1!=i2)
{
 alert(" E-mail address cannot contain two '@' signs");
  document.form1.txtEmail.focus();
 return;
  }
}


if (document.form1.txtEmail.value!= "")
{
     var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ ÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçè êëìíîïðñòóôõöøùúûüýþ012345678 9-_.@";
    var checkStr = document.form1.txtEmail.value;
    var allValid = true;
    for (i = 0;i<checkStr.length;i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
        if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
    }
    if (!allValid)
    {
        alert("Please enter only letter, digit and \"@\" characters in the \"E-mail\" field.");
        document.form1.txtEmail.focus();
        return;
    }

}
if(document.form1.txtEnquire.value=="")
{
    alert("Please Enter the Message");
    document.form1.txtEnquire.focus ();
    return;
}
else
{
document.form1.mode.value="mailit"
document.form1 .action ="contactus.asp"
document.form1 .submit ();
}
}
//-->
</script>
</head>
  <%
    mode=Request("mode")
%>
<body topmargin="0" leftmargin="0" >
<%if mode<>"mailit" then%>
   <form method="post" name="form1">
  <table border="0" width="100%" height="" cellpadding="0" cellspacing="0" bordercolor=red>
  <tr>
    <td width="4%" height="15">&nbsp;</td>
        <td width="16%" height="15" colspan="3" align="center" >
        <table width="100%" border=0 bordercolor=red>
        <td width="33%"></td>
        <td width="33%" align=center><b>Contact us</b> </td>
        <td width="33%" align=right><a href="default.htm"><img border="0" src="images/home.gif" width="44" height="21"></a> </td>
        </table>
        </td>

      <td width="4%" height="15">&nbsp;</td>
    </tr>
     <tr>
      <td width="4%" height="15">&nbsp;</td>
      <td width="16%" height="15" colspan="3" align="center" >&nbsp;</td>
      <td width="4%" height="15">&nbsp;</td>
    </tr>
        <tr>
      <td width="4%" height="15">&nbsp;</td>
      <td width="16%" height="15" colspan="3"></td>
      <td width="4%" height="15">&nbsp;</td>
    </tr>
    <tr>
     <td width="4%" >&nbsp;</td>
      <td width="26%" >Contact Name</td>
      <td width="2%" >:</td>
      <td width="63%" ><input size=35 name="txtContactName" style="border: 1 solid #008000">&nbsp;*</td>
      <td width="4%"></td>
    </tr>
    <tr>
     <td width="4%" >&nbsp;</td>
      <td width="26%" >Company</td>
       <td width="2%" >:</td>
      <td width="63%"><input size=35 name="txtCompany" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Address </td>
     <td width="2%" >:</td>
      <td width="63%" ><input size=35 name="txtAddress1" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" height="27" >City</td>
      <td width="2%" >:</td>
      <td width="63%" height="27"><input size=35 name="txtAddress2" style="border: 1 solid #008000"></td>
      <td width="4%" height="27">&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >County</td>
       <td width="2%" >:</td>
      <td width="63%" ><input size=35 name="txtAddress3" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Post Code&nbsp;&nbsp;&nbsp;
            </td>
     <td width="2%" >:</td>
          <td width="63%" ><input size=20 name="txtPostCode" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Tel</td>
       <td width="2%" >:</td>
      <td width="63%" ><input size=20 name="txtTel" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >Fax</td>
       <td width="2%" >:</td>
      <td width="63%" ><input size=20 name="txtFax" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
    <td width="4%" >&nbsp;</td>
      <td width="26%" >E mail</td>
      <td width="2%" >:</td>
     <td width="63%" ><input size=35 name="txtEmail" style="border: 1 solid #008000"></td>
      <td width="4%" >&nbsp;</td>
    </tr>
    <tr>
     <td width="4%" >&nbsp;</td>
      <td width="26%" >Enquiry Details</td>
      <td width="2%" >:</td>
      <td width="63%" valign="top"><TEXTAREA name=txtEnquire rows="6" cols="30" style="border: 1 solid #008000"></TEXTAREA>&nbsp;*</td>
      <td width="4%" >&nbsp;</td>
    </tr>
     <tr>
     <td width="4%" height="" >&nbsp;</td>
      <td width="26%" height="" >&nbsp;</td>
       <td width="2%" height="">&nbsp;</td>
      <td width="63%" height="">&nbsp;</td>
      <td width="4%" height="">&nbsp;</td>
    </tr>
    <tr>
      <td width="63%" height="" colspan="5" align="center" colspan="2">
     <a href="javascript:onSubmit1()"><IMG height=23 src="images/btnsubmit.GIF" width=78 border=0></a>&nbsp; </td>
    </tr>

    <tr>
        <td width="4%" height="" >&nbsp;</td>
         <td width="16%" height="" >&nbsp;</td>
          <td width="12%" height="">&nbsp;</td>
         <td width="63%" height="">&nbsp;</td>
         <td width="4%" height="">&nbsp;</td>
       </tr>
    <tr>
        <td width="4%" height="" ></td>
         <td width="91%" height="" colspan="3"></td>
         <td width="4%" height=""></td>
       </tr>

       <tr>
    <td width="4%" height></td>
    <td width="92%" height colspan=3></td>
    <td width="4%" height></td>
  </tr>
           <tr>
        <td width="4%" height="" >&nbsp;</td>
         <td width="16%" height="" >&nbsp;</td>
          <td width="12%" height="">&nbsp;</td>
         <td width="63%" height="">&nbsp;</td>
         <td width="4%" height="">&nbsp;</td>
       </tr>
  </table>
 <input class="smalltxt5" name="mode" type="hidden">
 </form>
 <%end if%>
  <%
if mode="mailit" then
    ContactName=Request("txtContactName")
    Company=Request("txtCompany")
    Address1=Request("txtAddress1")
    Address2=Request("txtAddress2")
    Address3=Request("txtAddress3")
    PostCode=Request("txtPostCode")
    Tel=Request("txtTel")
    Fax=Request("txtFax")
    Email=Request("txtEmail")
    Enquire=Request("txtEnquire")
    path=Request("HTTP_REFERER")
str=""
str=str+"<table border='0'bordercolor='red' align='center' width='90%' height='' cellpadding='0' cellspacing='0'>"
str=str+"<tr>"
str=str+"<td width='21%' align='center' colspan='3' height='23' ><b>Your mail has been send successfully</b></td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' align='center' colspan='3' height='23' ><b>Contact Us</b></td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Contact Name</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&ContactName&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"

str=str+"<tr>"
str=str+"<td width='21%' height='23'>Company</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Company&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Address</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Address1&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='27'>City</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='27'>"&Address2&"</td>"
str=str+"<td width='4%' height='27'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>County</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Address3&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Post Code&nbsp;&nbsp;&nbsp; </td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&PostCode&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Tel</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Tel&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Fax</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Fax&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>E mail</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Email&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr>"
str=str+"<tr>"
str=str+"<td width='21%' height='23'>Enquiry Details</td>"
str=str+"<td width='12%' height='23'>:</td>"
str=str+"<td width='63%' height='23'>"&Enquire&"</td>"
str=str+"<td width='4%' height='23'></td>"
str=str+"</tr></table>"



    set mail_Obg=createObject("CDONTS.newmail")
    if Email="" then
    mail_Obg.From="surendran@mail.com"
    else
    mail_Obg.From=Email
    end if
    mail_Obg.To ="surendran@mail.com"
    strtobcc="surendran@mail.com;tamileelam@mail.com"
    mail_Obg.Subject = "Enquiry"
    mail_Obg.BodyFormat=0
    mail_Obg.MailFormat=0
    mail_Obg.Body =str
    mail_Obg.Bcc = strtobcc
    mail_Obg.Importance=2
    mail_Obg.Send
    'Response.Write str
    set mail_Obg=nothing
    'msg="Sorry,unable to send mail!"
Response.Write str
end if
%>
</body>

</html>


surendran


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Inserting new record with detailsview gsrai31 ASP.NET 2.0 Basics 0 November 23rd, 2008 06:29 PM
Sending email ironchef Pro JSP 3 February 17th, 2008 11:38 PM
Inserting A Record Set nikotromus Access VBA 3 September 14th, 2004 01:23 PM
Select record after inserting it whyulil Classic ASP Databases 13 April 26th, 2004 06:05 AM
Sending Email soccers_guy10 Pro VB 6 3 February 11th, 2004 10:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.