扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<%@ Page Language="VB" Debug="True" Explicit="True"%> <%@ Import Namespace="System.Data" %> <%@ 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 '链接数据库 'www.knowsky.com 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 Oledbconnection,txtsql As String) As OledbDataReader Dim cmd As OledbCommand cmd=new oledbcommand(txtsql,conn) readdb=cmd.executereader() End Function </SCRIPT> <p align="center"><font size="5" face="楷体_GB2312">邮件列表</font></p> <hr width="60%" size="1"> <div align="center"> <center> <table border="0" width="770"> <tr> <td width="100%"> <form method="POST" runat="Server"> <table border="0" width="100%" height="125"> <tr> <td width="15%" align="right" height="24"> 发送邮箱: </td> <td width="85%" height="24"><input type="text" name="sendmailbox" id="sendmailbox" size="50" runat="Server"/></td> </tr> <tr> <td width="15%" align="right" height="24"> 标题: </td> <td width="85%" height="24"><input type="text" name="subject" id="subject" size="50" runat="Server"/></td> </tr> <tr> <td width="15%" align="right" height="60">内容:</td> <td width="85%" height="60"><textarea rows="6" name="content" cols="80" id="content" runat="Server"/></textarea></td> </tr> <tr> <td width="15%" align="right" height="23">方式:</td> <td width="85%" height="23"><select size="1" name="mode" id="mode" runat="Server"> <option value="Text" selected>Text</option> <option value="HTML">HTML</option> </select></td> </tr> </table> <p align="center"><input type="button" value=" 提 交 " name="ok" onserverclick="sendmail" runat="Server"/></p> </form> <ASP:Label id="lbmsg" runat="Server"/> <p> </td> </tr> <tr> <td width="100%"></td> </tr> </table> </center> </div> </body> </html> |
|
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者