前段时间写的。。献丑了:
private static void SendMail(string fromAddress, string[] toAddresses, string smtpAddress, int smtpPort, bool isSSL, string username, string password, string subject, string body)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(fromAddress);
foreach (string thisAdd in toAddresses)
{
mail.To.Add(new MailAddress(thisAdd));
}
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient(smtpAddress);
smtp.Port = smtpPort;
smtp.Timeout = int.MaxValue;
smtp.EnableSsl = isSSL;
smtp.Credentials = new System.Net.NetworkCredential(username, password);
smtp.Send(mail);
}
回复 引用 查看