Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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
 
Old March 22nd, 2005, 08:57 AM
Authorized User
 
Join Date: Feb 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kumarop
Default it should work......

Hi all ,
i am attaching a form hwich should act like this
1) email should be sent and message of sucess should appear.
2) select file should get copied into c:/temp of web server.

result
 no perticular error is appering,but nothing but clear all form is happening,when i run email.asp.

please see ,any syntax error?

Code:
<%@ Language=VBScript %>

<% option explicit %>
<HTML>
<HEAD>
<%
dim conn,ObjCom
%>
<script language="javascript">
function fn_submit()
{
  if (document.forms[0].vto.value==null || document.forms[0].vto.value=="" )
            {
            alert ("to is empty ..");
            document.forms[0].vto.focus();
            return false;
            }
  else if (document.forms[0].vfrom.value==null || document.forms[0].vfrom.value=="" )
            {
            alert ("write your email address ..");
            document.forms[0].vfrom.focus();
            return false;
            }

  else 
      {    
            if(!validemail(document.forms[0].vto.value))
            {
              alert("You need to enter valid email adress in TO ");
              document.forms[0].vto.focus();
              return false;
            }
            if(!validemail(document.forms[0].vfrom.value))
            {
              alert("You need to enter valid email address in FROM");
              document.forms[0].vfrom.focus();
              return false;
            }

      document.forms[0].submit();
     }

}

function validemail(str) 
    {
      var strFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
      if (strFilter.test(str))
        { return true; }
      else
        { return false; }
    }

</script>
<%
 'If Request.Form("IsSubmitted") <> "" Then
 If Request.Form("btnSubmit") <> "" Then                   
                     if Trim(Request(""))<>"" then
                            Dim objUpload, lngLoop,filename,filename1
                            If Request.TotalBytes > 0 Then
                            Set objUpload = New vbsUpload
                            For lngLoop = 0 to objUpload.Files.Count - 1
                                    'If accessing this page annonymously,
                                    'the internet guest account must have
                                    'write permission to the path below.
                            strPath=Server.MapPath("uploaded")
                            objUpload.Files.Item(lngLoop).Save "c:\temp\"
                            filename = objUpload.Files.Item(lngLoop).FileName()
                            filename1 = escape(filename)
                                    'urltogo = "/table_import.asp?table=" & filename1
                                    'Response.Redirect sendemail.asp
                            Next
                            End if 
                      else
                     'end if
  'If Request.Form("btnSubmit") <> "" Then
  'If Request.Form("IsSubmitted") <> "" Then
%>
     <table>
     <tr>
     <td></td>
<%     

                    Dim tcc,tto,tbcc,tsubject,tmessage,tfrom
                    tmessage = Request.Form("vmessage")
                    tto  = Request.Form("vto")
                    tcc = Request.Form("vcc")
                    tbcc = Request.Form("vbcc")
                    tsubject = Request.Form("vsubject")
                    tfrom = Request.Form("vfrom")
                    Const cdoSendUsingPort = 2
                    Dim oConfiguration
                    Dim oMessage
                    Dim oFields
                    Set oMessage = CreateObject("CDO.Message")
                    Set oConfiguration = CreateObject("CDO.Configuration")
                    Set oFields = oConfiguration.Fields
                    With oFields
                    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _
                        = cdoSendUsingPort
                    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
                        = "10.xx.1.1" 
                    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
                          = 100 
                    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") _
                        = 10 
                    'for priority
                    .Item("urn:schemas:mailheader:X-MSMail-Priority") = 0 
                    .Update
                    End With
                    'Apply the settings to the message.
                         With oMessage
                              Set .Configuration = oConfiguration
                              .To   = tto
                              .Bcc  = tbcc
                              .CC   = tcc
                              .From = tfrom
                              .Subject = tsubject
                              .HTMLBody = "<table border = 0 align =top  cellspacing = 1 cellpadding = 1><tr><td><pre>" & tmessage &"</td></tr></pre></table>"
                             '.AddAttachment ("C:\sample.jpg")
                              .Send
                         End With
                    'Clean up variables.
                    Set oMessage = Nothing
                    Set oConfiguration = Nothing
                    Set oFields = Nothing

%>
                    <script language = "javascript">    
                    alert("Mail Sent Sucessfully");
                    </script>
</table>
<%   
       end if
       End If                     
%>
</HEAD>
<BODY>
<form id="frmSendEmail" enctype="multipart/form-data" name="frmSendEmail" method="post" action=<%=request.servervariables("script_name")%> onSubmit="return fn_submit()">
    <table border = "0" align ="top"  cellspacing = 1 cellpadding = 1 width = "80%">
    <tr><td ALIGN=middle valign = top colspan =2>  Send Email&nbsp; </td></tr>

    <tr><td align=middle valign =top colspan=2><b>To prevent abuse, your IP Address (<%= Request.ServerVariables("http_host")%>)will be logged and recorded for this email message..</b></td></tr>

    <tr bgcolor="#eeeeee">      
          <td align = left rowspan = 6 width = "30%">Your email:<BR><input name = "vfrom" id = "vfrom" 
      style="WIDTH: 179px; HEIGHT: 22px" size=23> * <BR><%=now()%>(MM/DD/YYYY)</td></tr>

    <tr bgcolor="#eeeeee"> 
         <td ALIGN=left><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      To:&nbsp;<input name="vto" id="vto" style="WIDTH: 396px; HEIGHT: 22px" size=48></STRONG></td></tr>
   <tr bgcolor="#eeeeee">
        <td ALIGN=left><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &nbsp;cc:</STRONG><input name="vcc" id="vcc" style="WIDTH: 396px; HEIGHT: 22px" size=49></td></tr>
   <tr bgcolor="#eeeeee">
        <td align=left><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      bcc:</STRONG><input name="vbcc" id="vbcc" style="WIDTH: 396px; HEIGHT: 22px" size=48> </td></tr>
   <tr bgcolor="#eeeeee">
        <td ALIGN=left valign = top><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      Subject:</STRONG><input name="vsubject" id="vsubject" style="WIDTH: 396px; HEIGHT: 22px" size=46></td></tr>

   <tr bgcolor="#eeeeee">     
        <td align=left colspan=3><strong>Upload File:</strong><input type=file name=YourFile  size=35><input type=submit name=submit value="Upload"></td></tr>  

    <tr bgcolor="#eeeeee">
        <td ALIGN=left colspan=2><STRONG>Your message:</STRONG> </td></tr>
    <tr bgcolor="#eeeeee">
        <td align = left colspan =2><TEXTAREA id=vmessage name=vmessage rows=5 wrap=physical cols=80></TEXTAREA></td></tr><br>
    <tr bgcolor="#eeeeee"><td align=left colspan=2><input type="submit" name="btnSubmit" id="btnSubmit"
          value="Send Message" > </td></tr>
    <tr bgcolor="white">
         <td  align = middle colspan=3><p><A href="JavaScript:onClick=window.close()">Close Window</A></p>
    </td></tr>      
</table>
<!--
<input type="hidden" value= "True" name="IsSubmitted" >
-->
</form>            

</BODY>
</HTML>
om prakash kumar
__________________
om prakash kumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1 Ctrl+F5 don't work, F5 does work? jimboak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 June 29th, 2008 03:46 AM
why it doesn't work sangfroid C# 2005 2 January 21st, 2008 02:38 PM
Ok, this should work but it is not polorboy PHP How-To 0 January 25th, 2007 01:34 PM
Able to Get it work !! rsrika C# 2005 0 March 8th, 2006 09:16 AM
Why this example doesn't work DietCoke ASP.NET 1.0 and 1.1 Basics 3 November 29th, 2004 01:17 AM





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