<%@ Import Namespace="System.Web.Mail"%> <%@ Page Language="C#" Debug="true" %> <script runat="server"> void btnSend_Click(object sender,EventArgs e) { MailMessage myMail = new MailMessage(); myMail.To = this.txtTo.Text; myMail.From = "<" + this.txtFromEmail.Text + ">" + this.txtFromName.Text; myMail.Subject = this.txtSubject.Text; myMail.BodyFormat = MailFormat.Html; myMail.Body = this.txtDescription.Text.Replace("\n","<br>"); SmtpMail.Send(myMail); myMail = null; this.pnlForm.Visible = false; this.lblText.Text = "Mail Sending."; } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - Send Mail</title> </head> <body> <form id="form1" runat="server"> <asp:Panel id="pnlForm" runat="server"> <table width="343" border="1"> <tr> <td>To</td> <td><asp:TextBox id="txtTo" runat="server" Width="155px"></asp:TextBox></td> </tr> <tr> <td>Subject</td> <td><asp:TextBox id="txtSubject" runat="server"></asp:TextBox></td> </tr> <tr> <td>Description</td> <td><asp:TextBox ID="txtDescription" runat="server" Rows="4" TextMode="MultiLine"></asp:TextBox></td> </tr> <tr> <td>Form Name</td> <td><asp:TextBox id="txtFromName" runat="server"></asp:TextBox></td> </tr> <tr> <tr> <td>Form Email</td> <td><asp:TextBox id="txtFromEmail" runat="server"></asp:TextBox></asp:TextBox></td> </tr> <tr> <td> </td> <td><asp:Button id="btnSend" onclick="btnSend_Click" runat="server" Text="Send"></asp:Button></td> </tr> </table> </asp:Panel> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท