Proper email sending class asp.net 4.0 IIS 7.5 SMTP

tonisnail

New Member
Does anybody have proper email sending class for asp.net 4.0 c# ?Currently i have something like belowWhat suggestions would you make this below class ?\[code\]public static string sendEmail(string srEmailAddress, string srFrom, string srSubject, string srBodyHTML, string srBodyText){ using (MailMessage Email = new MailMessage(new MailAddress("[email protected]", 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(); } }}\[/code\]c# 4.0 asp.net 4.0 IIS 7.5
 
Back
Top