Try using the following code, hope it will work. Change credentials (UserName & Password) and receiver address according to yours.
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential("gmailusername@gmail.com", "gmailpassword");
client.UseDefaultCredentials = false;
client.Credentials = credentials;
MailMessage msg = new MailMessage();
msg.From = new MailAddress("gmailusername@gmail.com");
msg.To.Add(new MailAddress("xyz@gmail.com"));
msg.Subject = "This is a test Email subject";
msg.IsBodyHtml = true;
msg.Body = string.Format("<html><head></head><body>Test HTML Email</body>");
try
{
client.Send(msg);
}
catch (Exception ex)
{
}
Make sure you have removed all mail settings from your web.config file.
Let me know if there is any issue.