在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/// <summary> /// 发送邮件 /// </summary> /// <param></param> /// <param></param> private void sendMail(string title, string body) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); SystemConfig config = new SystemConfig(); doc.Load(Application.StartupPath + Constants.ConfigFileName); for (int i = 0; i < SystemConfig.ConfigItems.GetLength(0); i++) { config[SystemConfig.ConfigItems[i, 1]] = doc.SelectSingleNode(SystemConfig.ConfigItems[i, 0]).InnerText; } MailMessage mail = new MailMessage(); mail.From = new MailAddress(config["from"], config["from"]); mail.To.Add(config["to"]); mail.CC.Add(config["cc"]); mail.Subject = title; mail.Body = body;
//邮件服务器和端口 SmtpClient smtp = new SmtpClient(config["host"], 25); smtp.UseDefaultCredentials = true; //指定发送方式 smtp.DeliveryMethod = SmtpDeliveryMethod.Network; //指定登录名和密码 smtp.Credentials = new System.Net.NetworkCredential(config["SMTPUSERNAME"], config["SMTPPASSWORD"]); smtp.Send(mail); } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论