/// <summary> /// 邮件群发 /// </summary> /// <param name="strMyEmail">发送人邮件名</param> /// <param name="strMyPass">发送人密码</param> /// <param name="strMySmtp">发送人邮箱Smtp地址</param> /// <param name="strToEmail">接收人邮件名</param> /// <param name="strSubject">发送主题</param> /// <param name="strContent">发送内容</param> /// <param name="strIsHTML">是否为html</param> /// <param name="strFileArray">发送上传的路径</param> public static bool SendEmails(string strMyEmail, string strMyPass, string strMySmtp, List<string> strToEmail, string strSubject, string strContent, bool strIsHTML, string[] strFileArray) { try { MailMessage message = new MailMessage(); message.From = new MailAddress(strMyEmail); foreach (string item in strToEmail) { message.To.Add(new MailAddress(item));//接收人邮箱 } //message.To.Add(new MailAddress(strMyEmail)); message.Subject = strSubject;//主题 message.Body = strContent;//发送内容 message.IsBodyHtml = strIsHTML; if (strFileArray != null) { for (int i = 0; i < strFileArray.Length; i++) { Attachment data = new Attachment(strFileArray[i], MediaTypeNames.Application.Octet); ContentDisposition disposition = data.ContentDisposition; disposition.CreationDate = System.IO.File.GetCreationTime(strFileArray[i]); disposition.ModificationDate = System.IO.File.GetLastWriteTime(strFileArray[i]); disposition.ReadDate = System.IO.File.GetLastAccessTime(strFileArray[i]); message.Attachments.Add(data); } } SmtpClient client = new SmtpClient(strMySmtp, 25); client.Credentials = new System.Net.NetworkCredential(strMyEmail, strMyPass); client.Send(message); return true; } catch (Exception) { return false; } }