using System.Net.Mail;
protected void Button1_Click(object sender, EventArgs e)
{
string sendFrom = "yourmailaddress@gmail.com";
string toAddress = "tomailaddress@gmail.com";
string subject = "Test";
string mailBody = "Test";
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
MailMessage message = new MailMessage(sendFrom, toAddress, subject, mailBody);
message.IsBodyHtml = true;
client.Send(message);
}
web.config
<system.net>
<mailsettings>
<smtp from="yourmailaddress@gmail.com" deliveryMethod="Network">
<network host="smtp.gmail.com" port="25" userName="yourmailaddress@gmail.com" password="test123" />
</smtp>
</mailsettings>
</system.net>
</system.web
If this helped you then Please vote.