<%@ Import Namespace="System.Web.Mail"%> <%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(object sender,EventArgs e) { MailMessage myMail = new MailMessage(); String strMsg; myMail.To = "[email protected]"; myMail.From = "[email protected]"; myMail.Subject = "My Subject"; //*** HTML Tag ***// strMsg = ""; strMsg = strMsg +"<h1>My Message</h1><br>"; strMsg = strMsg +"<table width='285' border='1'>"; strMsg = strMsg +" <tr>"; strMsg = strMsg +" <td><div align='center'><strong>My Message </strong></div></td>"; strMsg = strMsg +" <td><div align='center'><font color='red'>My Message</font></div></td>"; strMsg = strMsg +" <td><div align='center'><font size='2'>My Message</font></div></td>"; strMsg = strMsg +" </tr>"; strMsg = strMsg +" <tr>"; strMsg = strMsg +" <td><div align='center'>My Message</div></td>"; strMsg = strMsg +" <td><div align='center'>My Message</div></td>"; strMsg = strMsg +" <td><div align='center'>My Message</div></td>"; strMsg = strMsg +" </tr>"; strMsg = strMsg +" <tr>"; strMsg = strMsg +" <td><div align='center'>"+ DateTime.Now.ToString() +"</div></td>"; strMsg = strMsg +" <td><div align='center'>"+ DateTime.Now.ToString() +"</div></td>"; strMsg = strMsg +" <td><div align='center'>"+ DateTime.Now.ToString() +"</div></td>"; strMsg = strMsg +" </tr>"; strMsg = strMsg +"</table>"; myMail.BodyFormat = MailFormat.Html; myMail.Body = strMsg; SmtpMail.Send(myMail); myMail = null; this.lblText.Text = "Mail Sending."; } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - Send Mail</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท