我有 2 个文件,一个 SendEmail.asp 和一个 Home.htm 文件。
在 Home.htm 中,我通过以下方式将 VB 脚本中的一些值传递给 SendEmail:
document.formname.action = "SendEmail.asp?homepage =" + window.location.href;
现在,当电子邮件成功完成后,我想将参数发送到 htm 文件并显示成功消息。
现在我以这种方式重定向到 home.htm:
response.redirect(request.QueryString("homepage"))
如果我添加任何查询字符串,home.htm?n1=success
那么我会收到错误消息。请提出您宝贵的建议和答案。
home.htm 文件中的代码:
<script language="javascript" type="text/javascript">
function fnSubmit()
{
var retValue=true;
if(retValue)
{
if(document.formname.txtName.value=='')
{
alert("Please enter Name");
document.formname.txtName.focus();
retValue=false;
}
}
if(retValue)
{
if(checkEmail(document.formname.txtEmail, "Email", false)==false)
{
alert("Please enter Email");
document.formname.txtEmail.focus();
retValue=false;
}
}
if(retValue)
{
if(document.formname.txtPhone.value=='')
{
alert("Please enter Phone No.");
document.formname.txtPhone.focus();
retValue=false;
}
}
if(retValue)
{
if(document.formname.txtQuery.value=='')
{
alert("Please enter Your Query");
document.formname.txtQuery.focus();
retValue=false;
}
}
if(retValue)
{
document.formname.action = "SendEmail.asp?homepage =" + window.location.href;
document.formname.submit();
}
return false;
</script>
点击按钮:
onclick="javascript:fnSubmit();"
在 SendEmail.asp 文件中:
<%@ language="VBScript" %>
<%Option Explicit%>
<%
Dim Uploader, File, FileSys, FilePath, UploadFileName, strHTML, subject, Mailer, EmailAddress
subject = request("txtSubject")
EmailAddress = request("txtEmail")
strHTML = " Name : "&request("txtName")&" Email : "&request("txtEmail")&" Query : "&request("txtQuery")
Set Mailer=CreateObject("CDO.Message")
Mailer.Subject="accurate-data-entry.com:: new"&subject
Mailer.From= request("txtEmail")
Mailer.To="abc@gmail.com "
Mailer.HTMLBody=strHTML
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com"
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=465
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") ="abc@gmail.com"
Mailer.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xyz"
Mailer.Configuration.Fields.Update
Mailer.send
Set Mailer = nothing
'Response.write("Done Successful")
response.redirect(request.QueryString("homepage "))
%>
如果我添加 Response.Write 我收到错误消息:
CDO.Message.1 错误“80040213”
传输无法连接到服务器。
/SendEmail.asp,第 41 行
第 41 行是 Mailer.send
谢谢