C#發送mail

  • 63
  • 0
  • 2018-08-14

C#發送mail

MailMessage mail = new MailMessage();
                mail.From= new MailAddress(ConfigurationSettings.AppSettings["MailFrom"]);
                mail.To.Add(ConfigurationSettings.AppSettings["MailTo"]);
                mail.Subject = "MailService Count over Setting";

                mail.IsBodyHtml = true;//有無html格式
                mail.Body = Body;

                SmtpClient smtpclient = new SmtpClient();
                smtpclient.Host = ConfigurationSettings.AppSettings["MailServer"];//設定SMTP Server

                smtpclient.Send(mail);