Send an Email with System.Net.Mail.MailMessage
private static void SendEmail(string name, string emailto, string emailfrom, string subject, string body, string mailserver, bool html)
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add(String.Format("{0}<{1}>", name, emailto));
message.From = new System.Net.Mail.MailAddress(emailfrom);
message.Subject = subject;
message.IsBodyHtml = html;
message.Body = body;
string success = SmtpSend(mailserver, message);
}
private static string SmtpSend(string mailserver, System.Net.Mail.MailMessage message)
{
try
{
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(mailserver);
smtp.Send(message);
return ("true");
}
catch (Exception e)
{
return (e.ToString());
}
}