using System.Net;
c#
---------------------------------------------------------------------------------------string fromEmail = "service@gmail.com";
string fromName = "Manager";
MailAddress from = new MailAddress(fromEmail, fromName, Encoding.UTF8);
string toEmail = "tony1017888@gmail.com";
MailMessage mail = new MailMessage(from, new MailAddress(toEmail));
string subject = "Test Subject";
mail.Subject = subject;
mail.SubjectEncoding = Encoding.UTF8;
string body = "Test Body";
mail.Body = body;
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = false;
mail.Priority = MailPriority.High;
// SMTP Setting
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 587;
client.Credentials = new NetworkCredential("username@gmail.com", "password");
client.EnableSsl = true;
// Send Mail
client.Send(mail);
// Sent Compeleted Eevet
//client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
張貼留言