有人有适合 asp.net 4.0 c# 的电子邮件发送类吗?
目前我有类似下面的东西
你会在课堂上提出什么建议?
public static string sendEmail(string srEmailAddress, string srFrom, string srSubject, string srBodyHTML, string srBodyText)
{
using (MailMessage Email = new MailMessage(new MailAddress("noreply@monstermmorpg.com", srFrom), new MailAddress(srEmailAddress)))
{
Email.IsBodyHtml = true;
Email.SubjectEncoding = Encoding.UTF8;
Email.BodyEncoding = Encoding.UTF8;
Email.Subject = srSubject;
using (AlternateView textPart = AlternateView.CreateAlternateViewFromString(srBodyText, Encoding.UTF8, "text/plain"))
{
textPart.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
Email.AlternateViews.Add(textPart);
}
using (AlternateView htmlPart = AlternateView.CreateAlternateViewFromString(srBodyHTML, Encoding.UTF8, "text/html"))
{
htmlPart.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
Email.AlternateViews.Add(htmlPart);
}
try
{
using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Host = "127.0.0.1";
smtpClient.Port = 25;
smtpClient.Send(Email);
return "True";
}
}
catch (Exception E)
{
return E.Message.ToString();
}
}
}
c# 4.0 asp.net 4.0 IIS 7.5