誰かがasp.net4.0c#用の適切な電子メール送信クラスを持っていますか?
現在、私は以下のようなものを持っています
クラスの下でこれをどのように提案しますか?
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