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.

If you want to send email using your Gmail account or using smtp server of Gmail in ASP.NET application or if you don't have a working smtp server to send mails using your ASP.NET application or aspx page than sending e-mail using Gmail is best option.

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

Popular posts from this blog

Asynchronous Socket Programming in C#

Url Routing MVC TUTORIAL

WCF Chat Sample