How to send email in asp.net
Web.config
<appSettings>
<add key=”SMTP” value=”smtp.gmail.com”/>
<add key=”FROMEMAIL” value=”Gmail UserName”/>
<add key=”FROMPWD” value=”GiveGmailPassword”/>
</appSettings>
give correct gmail username like lokeshasp@gmail.com
give correct gmail password
Giving correct username and password of gmail. Gmail SMTP server will assume is an authenticated user. For this authenticated details of gmail mails will sent to yahoo,gmail,etc..
using System.Net.Mail;
write below code in page load or button click
MailMessage mail = new MailMessage();
mail.To.Add(”lokeshdotnet09@yahoo.com”);
mail.From = new MailAddress(”lokeshasp@gmail.com”);
mail.Subject = “Test Email”;
string Body = “<b>Welcome to lotus.Com!!</b>”;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["SMTP"];
smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], ConfigurationManager.AppSettings["FROMPWD"]);
smtp.EnableSsl = true;
smtp.Send(mail);
