วันพุธที่ 12 มีนาคม พ.ศ. 2557

sent Email in C#

step 1
using System.Net.Mail
using System.Net

step 2
create mail ,mailto,mail from,mail body,mail subject
MailMessage myMail = new MailMessage();
myMail.From = new MailAddress("info@travexgo.com");
myMail.To.Add(new MailAddress(TextBox4.Text));
myMail.IsBodyHtml = true;
myMail.Subject = "Booking";
myMail.Body ="เนื้อความ"

Step 3
กำหนด Smtp
SmtpClient sm = new SmtpClient("smtp domain");
sm.Port = 25;
sm.Credentials = new NetworkCredential("User", "Password");

Step 4
ทำการส่งโดยใช้ SMTP และ เคลียค่าเมลล์
sm.Send(myMail1);
myMail1 = null;

ไม่มีความคิดเห็น:

แสดงความคิดเห็น