前台页面邮件发送测试
2024-07-21 02:24:37
供稿:网友
<%@ page language="c#" codebehind="webform1.aspx.cs" autoeventwireup="false" inherits="test.sendmailsample" %>
<html>
<head>
<title>邮件发送例子</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css">td {
font-size: 9pt; font-family: "宋体"
}
.textbox {
border-right: #000000 thin dashed; border-top: #000000 thin dashed; border-left: #000000 thin dashed; border-bottom: #000000 thin dashed
}
</style>
</head>
<body text="#000000" bgcolor="#ffffff">
<form runat="server">
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="3" width="500" align="center" border="1">
<tr>
<td align="middle" colspan="2">邮件发送例子(socket类)</td>
</tr>
<asp:panel id="pelmessage" visible="false" runat="server">
<tr>
<td align="middle" colspan="2">
<asp:label id="lblmessage" runat="server"></asp:label></td>
</tr>
</asp:panel>
<tr>
<td align="right" width="150">smtp服务器:</td>
<td width="350"><asp:textbox id="txtsmtphost" runat="server" cssclass="textbox" maxlength="50"></asp:textbox><asp:requiredfieldvalidator id="rfvsmtphost" runat="server" errormessage="*" controltovalidate="txtsmtphost" display="dynamic"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td align="right" width="150">smtp服务器端口:</td>
<td width="350"><asp:textbox id="txtport" runat="server" cssclass="textbox" maxlength="6"></asp:textbox><asp:requiredfieldvalidator id="rfvport" runat="server" errormessage="*" controltovalidate="txtport" display="dynamic"></asp:requiredfieldvalidator><asp:regularexpressionvalidator id="revport" runat="server" errormessage="只能输入数字" validationexpression="/d{1,}" controltovalidate="txtport" display="dynamic"></asp:regularexpressionvalidator></td>
</tr>
<tr>
<td align="right" width="150">邮件发送者:</td>
<td width="350"><asp:textbox id="txtfrom" runat="server" cssclass="textbox" maxlength="50"></asp:textbox><asp:requiredfieldvalidator id="rfvfrom" runat="server" errormessage="*" controltovalidate="txtfrom" display="dynamic"></asp:requiredfieldvalidator>
<asp:regularexpressionvalidator id="revfrom" runat="server" errormessage="邮件格式错误" validationexpression="/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*" controltovalidate="txtfrom" display="dynamic"></asp:regularexpressionvalidator></td>
</tr>
<tr>
<td align="right" width="150">发送者显示名称:</td>
<td width="350"><asp:textbox id="txtfromname" runat="server" cssclass="textbox" maxlength="20"></asp:textbox></td>
</tr>
<tr>
<td align="right" width="150">邮件接收者:</td>
<td width="350"><asp:textbox id="txtto" runat="server" cssclass="textbox" maxlength="50"></asp:textbox><asp:requiredfieldvalidator id="rfvto" runat="server" errormessage="*" controltovalidate="txtto" display="dynamic"></asp:requiredfieldvalidator>
<asp:regularexpressionvalidator id="revto" runat="server" errormessage="邮件格式错误" validationexpression="/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*" controltovalidate="txtto" display="dynamic"></asp:regularexpressionvalidator></td>
</tr>
<tr>
<td align="right" width="150">接收者显示名称:</td>
<td width="350"><asp:textbox id="txttoname" runat="server" cssclass="textbox" maxlength="20"></asp:textbox></td>
</tr>
<tr>
<td align="right" width="150">邮件发送优先级:</td>
<td width="350"><asp:dropdownlist id="ddlpriority" runat="server">
<asp:listitem value="高">高</asp:listitem>
<asp:listitem value="默认" selected="true">默认</asp:listitem>
<asp:listitem value="低">低</asp:listitem>
</asp:dropdownlist></td>
</tr>
<tr>
<td align="right" width="150">发送html格式的邮件:</td>
<td width="350"><asp:dropdownlist id="ddlhtml" runat="server">
<asp:listitem value="是" selected="true">是</asp:listitem>
<asp:listitem value="否">否</asp:listitem>
</asp:dropdownlist></td>
</tr>
<tr>
<td align="right" width="150">邮件主题:</td>
<td width="350"><asp:textbox id="txtsubject" runat="server" cssclass="textbox" maxlength="50"></asp:textbox>
<asp:requiredfieldvalidator id="rfvsubject" runat="server" errormessage="*" controltovalidate="txtsubject" display="dynamic"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td align="right" width="150">邮件内容:</td>
<td width="350">
<asp:textbox id="txtmessage" runat="server" rows="15" textmode="multiline" cssclass="textbox" columns="40"></asp:textbox>
<asp:requiredfieldvalidator id="rfvmessage" runat="server" errormessage="*" controltovalidate="txtmessage" display="dynamic"></asp:requiredfieldvalidator>
</td>
</tr>
<tr align="middle">
<td colspan="2">
<asp:button id="btnsendmail" runat="server" text="发送邮件" cssclass="textbox" backcolor="silver" forecolor="blue"></asp:button>
</td>
</tr>
</table>
</form>
</body>
</html>