ASP.NET 2.0 - Gmail 이용해서 메일 보내기
2014. 7. 23. 13:19
using System.Net.Mail; Mail mail = new Mail(); MailMessage message = new MailMessage(); message.To.Add(email); message.From = new MailAddress("userid@gmail.com"); message.Subject = "Test mail"; message.IsBodyHtml = false; message.Body = "This is a test message."; public bool sendMail(MailMessage message) { SmtpClient smtp = new SmtpClient(); bool result = true; try { smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.UseDefaultCredentials = true; smtp.Credentials = new System.Net.NetworkCredential("userid@gmail.com", "password"); smtp.Send(message); } catch (Exception exp) { result = false; } return result; }