Friday, July 10, 2009

Send Email from your GMAIL account using ASP.Net and C#

In this article i am going to explane about sending email in 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 and C#
protected void btnSendEmail_Click(object sender, EventArgs e) {   MailMessage mail = new MailMessage();   mail.To.Add("");   mail.From = new MailAddress("");   mail.Subject = "This email from using gmail";    string Body = "Hi this testing email from using gmail";   mail.Body = Body;    mail.IsBodyHtml = true;   SmtpClient smtp = new SmtpClient();   smtp.Host = "";   smtp.Credentials = new System.Net.NetworkCredential        ("","yourgmailpassword");   smtp.EnableSsl = true;   smtp.Send(mail); }
Please change from emailid and toemail id and put your gmail id and password.

No comments: