<%@ Register TagPrefix="Title" TagName="TitleShow" Src="/aspnetdata/Title.ascx" %>
<%@ Import Namespace="System.Web.Mail" %>
<html>
  <script language="C#" runat=server>
	void sendMail_Click(object sender,EventArgs e){
		MailMessage NewMail = new MailMessage();
		NewMail.To=ToE.Text;//收件人
		NewMail.Cc=ToEC.Text;
		NewMail.Bcc=ToEBC.Text;
		NewMail.Subject=Subject.Text;//主题
		NewMail.From=SendE.Text;//发送人
		if(Frm.SelectedItem.Value == "Text"){//判断格式
			NewMail.BodyFormat=MailFormat.Text;
		}
		else{
			NewMail.BodyFormat=MailFormat.Html;
		}
		NewMail.Body=TextBody.Text;//本文
		SmtpMail.Send(NewMail);//发送
	}
  </script>
<body background="/aspnetdata/images/winback.gif">
<Title:TitleShow id="BookT" Runat="server" />
    <form runat=server>
<table>
<tr><td align="right">收件人：</td><td><asp:Textbox Columns="30" ID="ToE" Runat="server" />
        <asp:RequiredFieldValidator id="ToER" ControlToValidate="ToE" Display="Dynamic" Font-Name="Arial" Font-Size="11" runat="server">
            必须输入收件人
        </asp:RequiredFieldValidator>
          <asp:RegularExpressionValidator id="ToERR" runat="server"
              ControlToValidate="ToE"
              ValidationExpression=".*@.*\..*"
              Display="Dynamic"
              Font-Name="verdana" 
              Font-Size="10pt">
                 电子邮件格式错误
          </asp:RegularExpressionValidator></td></tr>
<tr><td align="right">抄送收件人：</td><td><asp:Textbox Columns="30" ID="ToEC" Runat="server" /></td></tr>
<tr><td align="right">密件抄送收件人：</td><td><asp:Textbox Columns="30" ID="ToEBC" Runat="server" /></td></tr>
<tr><td align="right">发件人：</td><td><asp:Textbox Columns="30" ID="SendE" Runat="server" />
        <asp:RequiredFieldValidator id="SendER" ControlToValidate="SendE" Display="Dynamic" Font-Name="Arial" Font-Size="11" runat="server">
            必须输入发件人
        </asp:RequiredFieldValidator>
</td></tr>
<tr><td align="right">主题：</td><td><asp:Textbox Columns="30" ID="Subject" Runat="server" /></td></tr>
<tr><td align="right" valign="top">本文：<p>本文格式<asp:RadioButtonList id="Frm" runat="server">
            <asp:ListItem Selected="True">Text</asp:ListItem>
            <asp:ListItem >HTML</asp:ListItem>
        </asp:RadioButtonList></td><td><asp:Textbox ID="TextBody" Rows="7" Columns="45" TextMode="MultiLine" Runat="server" /></td></tr>
<tr><td align="center"><ASP:Button id="sendMail" Runat="server" Text="发送" onclick="sendMail_Click" /></td></tr>
</table>
    </form>
</body>

</html>