01.
try
02.
{
03.
MailMessage mail =
new
MailMessage();
04.
mail.To.Add(
"suppadetch.ya@gmail.com"
);
05.
mail.From =
new
MailAddress(
"suppadetch.ya@gmail.com"
);
06.
mail.Subject =
"sub"
;
07.
mail.Body =
"สวัสดี"
;
08.
mail.IsBodyHtml =
true
;
09.
SmtpClient smtp =
new
SmtpClient();
10.
smtp.Host =
"smtp.gmail.com"
;
11.
smtp.Credentials =
new
System.Net.NetworkCredential(
"suppadetch.ya@gmail.com"
,
"*********"
);
12.
smtp.Port = 587;
13.
14.
smtp.EnableSsl =
true
;
15.
smtp.Send(mail);
16.
MessageBox.Show(
"ส่งแล้ว"
);
17.
}
18.
catch
(Exception ex)
19.
{
20.
MessageBox.Show(
"Exception in sendEmail:"
+ ex.Message);
21.
}