First of all , It is required to configured GMail.
1. Create Gmail account or use existing if you already have it.
2. Log in into Gmail.
3. Go Settings.
4. Go Forwarding and Enable IMAP/POP3
5. In that go to last section and enable IMAP.
Now in your Web Application / Web Site project , open web.config. Add following to web.config.
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp.gmail.com" port="587" userName="username@gmail.com" password="password" />
</smtp>
</mailSettings>
</system.net>
GMail IMap Service runnig at port 587 so you must required to configured that. Also Gmail required SSL authentication so it is required to enable ssl for SMTPClient.
MailMessage message = new MailMessage();
message.From = new MailAddress(from@gmail.com);
message.To.Add("to@gmail.com");
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Send(message);
Yuo can not enable SSL in web.config so you must required to configure it explicitly.