Send Email from your GMAIL account using ASP.Net and C#
In this article i am going to explane about sending email in asp.net using your gmail account.
Here is the Example in asp.net and C#
protected void btnSendEmail_Click(object sender, EventArgs e) { MailMessage mail = new MailMessage(); mail.To.Add("toemailid@gmail.com"); mail.From = new MailAddress("fromemailid@gmail.com"); mail.Subject = "This email from asp.net using gmail"; string Body = "Hi this testing email from asp.net using gmail"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Credentials = new System.Net.NetworkCredential ("youremailid@gmail.com","yourgmailpassword"); smtp.EnableSsl = true; smtp.Send(mail); }
Please change from emailid and toemail id and put your gmail id and password.
Comments