- 爱易网页
-
ASP教程
- asp的有关问题,用
日期:2014-05-17 浏览次数:20983 次
asp的问题,急用
我设计的网上书店,我想让用户注册完之后,我的系统直接回复一个信息到到他的邮箱,代码怎么写?
------解决方案--------------------
去搜索一下jmail相关的资料看看
------解决方案--------------------
jmail实现:请确认你的服务器支持jmail组件
<% '======================================================================================
Dim ForUser, FromUser, ForUserEmail, FromUserEmail, SmtpServer
Dim emailTit, emailTxt, FromUserID, FromUserIDPW
emailTit = Request.Form( "emailTit ") '从表单获取email的标题
emailTxt = Request.Form( "emailTxt ") '从表单获取邮件的内容
'==========================以下绿色代码是判断服务器是否支持JMAIL组件
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
if not IsObjInstalled( "JMail.Message ") then
Response.write "你所使用的服务器不支持邮件发送! "
Response.End
end if
'==========================================================
if Trim(Request.Form( "action ")) = "确定发送 " then
SmtpServer = Request.Form( "SmtpServer ")
FromUserEmail = Request.Form( "FromUserEmail ")
FromUser = Request.Form( "FromUser ")
ForUserEmail = Request.Form( "ForUserEmail ")
FromUserID = Request.Form( "FromUserID ")
FromUserIDPW = Request.Form( "FromUserIDPW ")
Dim JMail
Set JMail=Server.CreateObject( "JMail.Message ")
JMail.Logging=True
JMail.Charset= "gb2312 "
JMail.ContentType = "text/HTML "
JMail.AddHeader "Originating-IP ", Request.ServerVariables( "REMOTE_ADDR ")
if Request.Form( "smtpPW ") = "1 " then '判断服务器是否需要身份验证
' 身份验证
JMail.MailServerUserName = FromUserID
' 身份验证的用户名
JMail.MailServerPassword = FromUserIDPW
' 身份验证的密码
end if
JMail.From = FromUserEmail '发件人的信箱
JMail.FromName = FromUser '发件人的名字
JMail.Subject = emailTit '邮件的主题
JMail.Body = emailTxt '邮件的内容
'==============================收件人的地址!
JMail.AddRecipient(ForUserEmail) '收件人的地址
JMail.Priority=5 '邮件级别1-5数字越大级别越高---3为普通邮件
JMail.Send(SmtpServer) '红色变量是邮件服务器地址
JMail.Close
Set JMail=nothing
if err then
err.clear
Response.Write " <center> <b> 发信功能已经打开,但因服务器不支持发信或者信箱地址错误,导致信件无法发出! </b> </center> "
Response.End
else
Response.Write " <center> <b> 信件已经发出! </b> </center> "
Response.End
end if
end if %>
<style type= "text/CSS ">
<!--
td {
font-size: 12px;
}
-->
</style>
<body leftmargin= "0 " topmargin= "2 " bgcolor= "#0066CC ">
<form action= " " method= "post " name= "input " target= "_self ">
<table width= "436 " border= "0 " align= "center " bgcolor= "#0066CC " cellpadding= "3 " cellspacing= "1 ">
<tr bgcolor= "#CADBF7 ">
<td width= "154 " align= "right " height= "28 "> 收件人名字: </td>
<td width= "267 " height= "28 " class= "text1 "> <input name= "ForUser " type= "text " value= "我容易么我 " size= "20 ">
</td>
</tr>