在本机用CDONTS发送邮件
作者:wang 日期:2009-04-25
email.asp
给我Email
....................................................................................................................
sentmail.asp
给我Email
<%
dim username
dim email,mubiaoEmailAddress
dim title
dim content
dim founderr
fouunderr=false
dim errmsg
username=trim(Request.form("username"))
email=trim(Request.Form("email"))
title=trim(Request.Form("title"))
mubiaoEmailAddress=trim(Request.Form("mubiaoEmailAddress"))
content=Request.Form("content")
if username="" then
errmsg="您的大名不能为空 "
founderr=true
end if
if IsValidEmail(email)=false then
errmsg=errmsg+"您的email有错误,否则没办法回复您的Email "
founderr=true
end if
if content="" then
errmsg=errmsg+"内容不能为空 "
founderr=true
end if
%>
height="17" class="tableclass">
<%
if founderr=false then
dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
response.write Email
response.write mubiaoEmailAddress
objCDOMail.From =Email
objCDOMail.To = mubiaoEmailAddress
objCDOMail.Subject =title
objCDOMail.Body = content
objCDOMail.Send
Set objCDOMail = Nothing
%>
<%
response.write " "
else
'end if
%>
<%
end if
%>
<%
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
%>
....................................................................................................................
sentmail.asp
<%
dim username
dim email,mubiaoEmailAddress
dim title
dim content
dim founderr
fouunderr=false
dim errmsg
username=trim(Request.form("username"))
email=trim(Request.Form("email"))
title=trim(Request.Form("title"))
mubiaoEmailAddress=trim(Request.Form("mubiaoEmailAddress"))
content=Request.Form("content")
if username="" then
errmsg="
founderr=true
end if
if IsValidEmail(email)=false then
errmsg=errmsg+"
founderr=true
end if
if content="" then
errmsg=errmsg+"
founderr=true
end if
%>
<%
if founderr=false then
dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
response.write Email
response.write mubiaoEmailAddress
objCDOMail.From =Email
objCDOMail.To = mubiaoEmailAddress
objCDOMail.Subject =title
objCDOMail.Body = content
objCDOMail.Send
Set objCDOMail = Nothing
%>
谢谢您的Email,xx会尽快处理您的Email,请再继续访问这里的其他栏目;
感谢您一如既往地对ASP123的支持,这里的建设离不开您的意见和建议!
<%
response.write "
else
'end if
%>
Sorry, 请再仔细检查以下的项目是否正确:
<%response.write errmsg%>
<%
end if
%>
<%
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
%>
[本日志由 wang 于 2009-09-25 09:30 AM 编辑]






评论: 0 | 引用: 0 | 查看次数: 2830
发表评论