主要是给我Windows服务器使用的,添加到计划任务执行了。
SmtpClient smtp = new SmtpClient("smtp.qq.com", 25); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("1912107736", "******"); MailMessage mail = new MailMessage(new MailAddress("[email protected]"),new MailAddress("[email protected]")); mail.Headers.Add("X-Priority", "3"); mail.Headers.Add("X-MSMail-Priority", "Normal"); mail.Headers.Add("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869"); mail.Headers.Add("X-MimeOLE", "Produced By Microsoft MimeOLE V6.00.2900.2869"); mail.Subject = "产学研基地服务器 - 用户登录"; mail.Body = String.Format("当前登录用户:{0}\n登陆时间:{1}", System.Environment.UserName,DateTime.Now.ToString()); mail.IsBodyHtml = false; smtp.Send(mail);