.NET and other interesting stuff.

January 2008 - Posts

Send mails from .NET

.NET offers a simple way to send mails from our applications.
We only need to create a instance of the class MailMessage, that will represent the email, and another instance of the class Smtp that will act like a Smtp Client to send the email.
Both of them are on the System.Net.Mail namespace.
The source code to use is very simple:

 MailMessage mail = new MailMessage(from, to, subject, content);

 SmtpClient client = new SmtpClient();


And we need to specify the configuration for the Smtp client. You can configure it to use an Exchange server.
That can be done on the App.Config / Web.Config.

Here is the configuration:


        <smtp deliveryMethod="Network">








More Posts