<%@ Import Namespace="System.Web.Mail"%> <%@ Page Language="C#" %> <script runat="server"> public void Page_Load(object sender, EventArgs e) { MailMessage myMail = new MailMessage(); myMail.To = "[email protected]"; myMail.From = "[email protected]"; myMail.Subject = "My Subject"; myMail.BodyFormat = MailFormat.Text; myMail.Body = "My Body & Description"; string strSMTP = null; string cdoSendUsingPort = null; string cdoBasic = null; string UserName = null; string Password = null; strSMTP = "localhost"; cdoSendUsingPort = "2"; cdoBasic = "1"; UserName = "weerachai"; Password = "password"; myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", strSMTP); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", UserName); myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Password); SmtpMail.SmtpServer = strSMTP; 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 ของทีมงานไทยครีเอท