Monday, February 25, 2008

To mail through C# 2.0 .NET 2.0 code.

Hi

Following is the code in C# 2.0 used to send mails...

Assembly to use:
System.Net.Mail

Code:

MailMessage message = new MailMessage("FromID@Email.com", "ToID@Email.com", "Test Mail Subject", "Message to Fauzi's Email ID");

SmtpClient emailClient = new SmtpClient("Your SMTP Client");

emailClient.UseDefaultCredentials = true;

emailClient.Send(message);

Note: Please check that your anti virus program is not blocking port number 25. By default the above code uses port #25.

That it! this will do...