Jmail是需要服务器上有Jmail组件的,]我有个不要组件的好办法,使用外部邮件服务器来实现,比如用163的邮箱,你的邮件地址为
suny@163.com,你的密码为123:
<%
dim strsubject,strquery
strsubject=trim("这里是邮件名称")
strquery=trim("这里是邮件内容")
Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort=2
Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic=1
Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"
Dim objConfig
Dim objMessage
Dim Fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.163.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "suny" '这里是你的邮箱用户名
.Item(cdoSendPassword) = "123" '这里是密码
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = "目标邮件地址"
.From = "网站来信<suny@163.com>" '收到的邮件会显示的来信名称为“网站来信”
.Subject = strsubject
.TextBody = strquery
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
response.write "<div align=center>邮件已发送成功,谢谢使用!<br><br><a href=javascript:window.close()>确定</a></div>"
%>
当然了,这里只是举个小例子,如果不想把密码和用户名放在ASP文件里,也可以放到数据库中来读取。
[此贴子已经被作者于2006-8-16 11:37:30编辑过]