Monday, May 28, 2007
Sending SMTP Email in C# - .NET 1.x and .2.0
Microsoft, at least with software development, have a tendency to be reasonably consistent, which is why I was surprised recently that the class structure of .NET 1.x and 2.0 have changed somewhat.
Code for sending email, .NET 1.1:
Code for sendmail email, .NET 2.0:
Code for sending email, .NET 1.1:
using System.Web.Util;
MailMessage mail = new MailMessage("from@addr.com", "to@addr.com",
"My subject", "Text body");
SmtpMail smtp("relay.server.com");
string res = SmtpMail.Send(mail);
Code for sendmail email, .NET 2.0:
using System.Net.Mail;
MailMessage mail = new MailMessage("from@addr.com", "to@addr.com",
"My subject", "Text body");
SmtpClient smtp("relay.server.com");
string res = smtp.Send(mail);
Subscribe to Posts [Atom]