public static bool Send(string SMTP, string mailFrom, string mailTos, string subject, string body, string user, string paw, MailPriority Priority = MailPriority.Normal) { MailMessage mailObj = new MailMessage(); mailObj.From = new MailAddress(mailFrom);//发信人地址 string[] strarray = mailTos.Split(‘;‘); foreach (string str in strarray) { mailObj.To.Add(str);//收信地址 } mailObj.Subject = subject;//邮件标题 mailObj.Body = body; //html格式的邮件 mailObj.IsBodyHtml = true; ////设置为高级优先权(可设可不设) mailObj.Priority = Priority; //使用SmtpMail对象发送邮件 SmtpClient smtp = new SmtpClient(SMTP); smtp.Credentials = new NetworkCredential(user, paw); smtp.Send(mailObj); return true; }
时间: 2024-10-19 13:00:28