Tuesday, January 25, 2011

Send Emails using C#.Net

Following is the code extract to send emails via C#.Net using an external SMTP server e.g. via a Gmail account or something similar.


System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
NetworkCredential loginInfo = new NetworkCredential("user", "password");
string hostname = "hostname";
int port = 99;

client.Host = hostname;
client.Port = port;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
msg.Subject = emailSubject;
msg.Body = emailMessage;
msg.IsBodyHtml = true;
client.Send(msg);

Remember to alter the hostname, port and credentials accordingly.

Sunday, January 9, 2011

MySQL DataAccess Layer with C#.Net

I have created a data-access layer for MySQL database in C#.Net.

- tested on MySQL database 5.1
- Dot Net Connector version 6.2.5
- Wrapper Parameter class to customize parameter handling
- Free and Open Source
- Sample Hello World Application

Download and Source Code Available at:
http://code.google.com/p/mysql-dataaccess/

Please feel free to extend it and use in your projects.

Sample Test Application