Another quick code snippet: sending ASCII e-mail easily
Posted: (EET/GMT+2)
Another quick C#/.NET code snippet for today. This time, the code below shows you how to easily send ASCII e-mail from the given sender to the given recipient:
private static void SendEmail(string from, string to,
string subject, string text)
{
MailMessage msg = new MailMessage(from,to);
msg.Subject = subject;
msg.IsBodyHtml = false;
msg.Body = text;
string server = "smtp.my-isp.com";
SmtpClient client = new SmtpClient(server);
client.Send(msg);
}
Simply enough from .NET 2.0 or later. Keywords: How to send e-mail from .NET, howto, MailMessage, SmtpClient.