ICaramba

Miguel Castro's blog about .NET and its effect on National Security, the Eco-system, and his daughter's sleeping patterns.


News

My Stats

  • Posts - 122
  • Comments - 68
  • Trackbacks - 145

Twitter












Recent Comments


Recent Posts


Archives



Blogs I read


Links


Microsoft DCCs


 

It seems that the protocol for sending email in .NET 2.0 has changed from what it was in 1.1.  The System.Web.Mail namespace has been replaced with the new System.Net.Mail names code samplepace.  The following is a C# code sample on how to send mail with 2.0:

System.Net.Mail.SmtpClient o_Client = new System.Net.Mail.SmtpClient(this.MailServer);
System.Net.Mail.MailAddress
o_FromAddress = new System.Net.Mail.MailAddress(this.FromEmail, this.FromName);
System.Net.Mail.MailAddress o_ToAddress = new System.Net.Mail.MailAddress(this.ToEmail, this
.ToEmail);
System.Net.Mail.MailMessage o_Message = new System.Net.Mail.MailMessage
(o_FromAddress, o_ToAddress);
o_Message.Subject = this
.Subject;
o_Message.Body = this
.Body;
o_Client.Send(o_Message);

The properties contained in “this“ should be obvious. As you can see, we now get a “friendly” send name so we no longer have to rig it as we did in 1.1.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati