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 </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>
To: <input name="vto" id="vto" style="WIDTH: 396px; HEIGHT: 22px" size=48></STRONG></td></tr>
<tr bgcolor="#eeeeee">
<td ALIGN=left><STRONG>
cc:</STRONG><input name="vcc" id="vcc" style="WIDTH: 396px; HEIGHT: 22px" size=49></td></tr>
<tr bgcolor="#eeeeee">
<td align=left><STRONG>
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>
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