t; <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> 程序运行界面如下(图一):
在以上的程序中,我们将一些比较常见的功能设置成为函数,在主体程序中直接调用这些函数,这样,程序看起来比较简洁,修改也很简单。在这里,我们简单介绍一下这些函数,一是连接数据库的ConnectDB(txtdatabase AS String),这个函数使用Access数据库的相对位置作为函数参数,返回数据库连接OleDbConnection;函数readdb(conn As Oledbconnection,txtsql As String)可以直接执行一条SQL语句,返回OledbDataReader。在程序中,我们将每一个邮件发送的结果保存并且最好生成一个HTML格式的日志文件。因为程序中我们用到了数据库、电子邮件和文件操作,以此,在引入名字空间的时候,我们需要将“System.Data.OleDb”、“System.Web.Mail”和“System.IO”引入。 在使用以上邮件列表程序的时候,我们需要注意几个问题,第一是Smtp服务器的设置,我们知道,Smtp服务器是邮件发送服务器,而现在一些免费邮件提供商是不再提供针对所有邮件提供Smtp服务,在发送邮件的时候,需要验证用户信息,而我们看到,在以上的程序中甚至整个ASP.NE
上一页 [1] [2] [3] [4] [5] 下一页 |