<%@ Import Namespace="System.Web.Mail"%> <%@ Page Language="C#" %> <script runat="server"> public void Page_Load(object sender, EventArgs e) { System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage(); System.Net.NetworkCredential Cred = new System.Net.NetworkCredential("[email protected]", "password"); myMail.To.Add("[email protected]"); myMail.Subject = "Test send mail message"; myMail.From = new System.Net.Mail.MailAddress("[email protected]"); myMail.IsBodyHtml = true; myMail.Body = "Hi Sawatdee.<br><br>Sabye dee mai."; System.Net.Mail.SmtpClient SmtpMail = new System.Net.Mail.SmtpClient("smtp.gmail.com"); SmtpMail.UseDefaultCredentials = false; SmtpMail.EnableSsl = true; SmtpMail.Credentials = Cred; SmtpMail.Port = 465; SmtpMail.Send(myMail); myMail = null; this.lblText.Text = "Mail Sending."; } </script> <html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท