public static string SendMail(string from, string to, string subject, string body, string smtp)
{
// Create new MailMessage Object
MailMessage message = new MailMessage(from, to, subject, body);
//message.Bcc.Add("someone@tobcc.com");
message.IsBodyHtml = true;
// Create new SmtpClient Object
SmtpClient mailClient = new SmtpClient(smtp, 25);
try
{
// Send eMail and return 1 if successful
// otherwise return error message
mailClient.Send(message);
return "1";
}
catch (System.Net.Mail.SmtpException e)
{
// create or append errors to a log file
CreateLogFiles.CreateLogFiles Err = new CreateLogFiles.CreateLogFiles();
Err.ErrorLog(System.Web.HttpContext.Current.Server.MapPath("/logs/ErrorLog.log"), e.InnerException.Message);
return e.InnerException.Message;
}
}
No comments:
Post a Comment