Tuesday, July 17, 2012

File Locking/Unlocking utility

Every now and then during testing we may require to lock particular files for testing different scenarios. this utility allows locking and unlocking files.

project home is at: http://code.google.com/p/filelocker/


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.