ot; %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.IO" %>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>邮件列表</title>
<style>
<!--
a:link{color:#0066FF;text-decoration:none;font-size:"9 pt"}
a:visited{color:#000066;text-decoration:none;font-size:"9 pt"}
a:actived{color:#FF0000;font-size:"9 pt"}
a:hover{color:#FF0000;font-size:"9 pt"}
table{font-size:"11 pt"}
-->
</style>
</head>
<body>
<SCRIPT language=VB RUNAT="server">
Sub SendMail(Obj As Object, E As EventArgs)
lbmsg.Text=""
Dim mailObj AS new MailMessage
Dim smtp AS new SmtpMail
''定义SMTP服务器的名称
Smtp.smtpserver="127.0.0.1"
''定义邮件的发送地址
mailObj.From=sendmailbox.value
''定义邮件的接收地址
Dim conn AS OleDbConnection
conn=connectdb("data\mail.mdb")
conn.open()
Dim reader As oledbdatareader
reader=readdb(conn,"select * from mail")
while (reader.read())
try
mailObj.To=reader("mail")
mailObj.Subject =subject.value
mailObj.Body =content.value
''默认发送邮件格式为纯文本TEXT,如果选择HTML格式,设置为HTML格式
if mode.value="HTML" then
mailObj.BodyFormat=MailFormat.Html
end if
''设置邮件发送级别为高
mailObj.Priority = MailPriority.High
Smtp.Send(mailObj)
lbmsg.text=lbmsg.text+reader("mail")+"OK!Time:"+Now().ToString()+"<br>"
catch er as Exception
lbmsg.text=lbmsg.text+er.message+"<br>"
finally
End Try
End While
reader.close()
Dim strwriterobj As StreamWriter
try
strwriterobj= File.CreateText(Server.MapPath("log\")+subject.value+".htm")
strwriterobj.Write("<HTML><head><meta http-equiv=''Content-Language'' content=''zh-cn''><meta http-equiv=''Content-Type'' content=''text/html; charset=gb2312''></head><BODY>"+lbmsg.text+"</BODY></HTML>")
catch er as Exception
lbmsg.text=lbmsg.text+er.message+"<br>"
finally
strwriterobj.close
lbmsg.text=lbmsg.text+"日志保存成功!保存目录:<br>"+Server.MapPath("log\")+subject.value+".htm"
End Try
End Sub
''链接数据库
Function ConnectDB(txtdatabase AS String) As Oledbconnection
Dim conn AS OledbConnection
Dim connstr As String
connstr="Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False; Data Source=" +Server.MapPath(txtdatabase)
connectdb=New OledbConnection(connstr)
End Function
''读取一条记录
Function readdb(conn As Oledbconnect