我在asp页面上有错误
错误“80040211”/contact_us1.asp,第 106 行
第 106 行是 ObjSendMail.Send 方法调用。下面的代码是整个通过 CDOSYS 发送电子邮件并且没有安装 smtp 服务器。
操作系统 - Windows Server2008R2,IIS - 7.5
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
'Declaring Variables
Dim smtpserver,youremail,yourpassword,ContactUs_Name,ContactUs_Tel,ContactUs_Email
Dim ContactUs_Subject,ContactUs_Body,Action,IsError
' Edit these 3 values accordingly.. leave the smtp server alone as it is set for Gmail
smtpserver = "smtp.gmail.com"
youremail = "someone@gmail.com"
yourpassword = "--------"
' Grabbing variables from the form post
ContactUs_Name = Request("ContactUs_Name")
ContactUs_Tel = Request("ContactUs_Tel")
ContactUs_Email = Request("ContactUs_Email")
ContactUs_Subject = Request("ContactUs_Subject")
ContactUs_Body = Request("ContactUs_Body")
Action = Request("Action")
' Used to check that the email entered is in a valid format
Function IsValidEmail(Email)
Dim ValidFlag,BadFlag,atCount,atLoop,SpecialFlag,UserName,DomainName,atChr,tAry1
ValidFlag = False
If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
atCount = 0
SpecialFlag = False
For atLoop = 1 To Len(Email)
atChr = Mid(Email, atLoop, 1)
If atChr = "@" Then atCount = atCount + 1
If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
Next
If (atCount = 1) And (SpecialFlag = False) Then
BadFlag = False
tAry1 = Split(Email, "@")
UserName = tAry1(0)
DomainName = tAry1(1)
If (UserName = "") Or (DomainName = "") Then BadFlag = True
If Mid(DomainName, 1, 1) = "." then BadFlag = True
If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
ValidFlag = True
End If
End If
If BadFlag = True Then ValidFlag = False
IsValidEmail = ValidFlag
End Function
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body class="oneColFixCtrHdr" onload="P7_initPM(0,0,1,-20,10)">
<%
' If there were no input errors and the action of the form is "SendEMail" we send the email off
If Action = "SendEmail" Then
Dim strBody
' Here we create a nice looking html body for the email
strBody = strBody & "<font face=""Arial"">Contact Us Form submitted at " & Now() & vbCrLf & "<br><br>"
' strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") & vbCrLf & "<br>"
' strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "<br>"
strBody = strBody & "Name" & " : " & " " & Replace(ContactUs_Name,vbCr,"<br>") & "<br>"
strBody = strBody & "Tel." & " : " & " " & Replace(ContactUs_Tel,vbCr,"<br>") & "<br>"
strBody = strBody & "Email" & " : " & " " & Replace(ContactUs_Email,vbCr,"<br>") & "<br>"
strBody = strBody & "Subject" & " : " & " " & Replace(ContactUs_Subject,vbCr,"<br>") & "<br>"
strBody = strBody & "<br>" & Replace(ContactUs_Body,vbCr,"<br>") & "<br>"
strBody = strBody & "</font>"
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") = "smtp.gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 'Use SSL for the connection
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
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") = "someone@gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "----------"
ObjSendMail.Configuration.Fields.Update
'End remote SMTP server configuration section==
ObjSendMail.To = youremail
ObjSendMail.CC = "karapetyan.manuk@gmail.com;kmanuk@mail.ru"
ObjSendMail.Subject = ContactUs_Subject
ObjSendMail.From = ContactUs_Email
' we are sending a html email.. simply switch the comments around to send a text email instead
ObjSendMail.HTMLBody = strBody
'ObjSendMail.TextBody = strBody
ObjSendMail.Send
Set ObjSendMail = Nothing
' change the success messages below to say or do whatever you like
' you could do a response.redirect or offer a hyperlink somewhere.. etc etc
%>
<font size="12">Message uxarkvec barehajox</font>
<%
Else
%>
<form action="contact_us1.asp" method="POST">
<input type="hidden" name="Action" value="SendEmail">
<table border="0" cellspacing="1" style="font-size:14px; font-family:Verdana, Geneva, sans-serif;">
<tr>
<td valign="top">
Full Name:
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="ContactUs_Name" size="35" value="<% =ContactUs_Name %>" required>
</td>
</tr>
<tr>
<td valign="top">
Tel.:
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="ContactUs_Tel" size="35" value="<% =ContactUs_Tel %>">
</td>
</tr>
<tr>
<td valign="top">
Email:
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="ContactUs_Email" size="35" value="<% =ContactUs_Email %>" required>
</td>
</tr>
<tr>
<td valign="top">
Subject:
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="ContactUs_Subject" value="<% =ContactUs_Subject %>" size="35">
</td>
</tr>
<tr>
<td valign="top">
Message:
</td>
</tr>
<tr>
<td valign="top">
<textarea cols="60" name="ContactUs_Body" wrap="soft" style="resize:none; height: 150px" required><% =ContactUs_Body %></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Send Message" style="font-size:16px">
</td>
</tr>
</table>
</form>
<%
End If
%>
</body>
</html>
请帮我解决这个问题。