How to Send Emails from Google SMTP

I came into an issue where I need to send an email from my website.. I don’t have an SMTP service installed on my web server and I didn’t want to go into that path for many of my personal reasons. so I decided to go with Google SMTP service as it is free as well as it is accessible from anywhere.. to accomplish this task it took from me 15 minutes.. so I thought of sharing my code with you as well

public void SendEmail ()
{

var client = new SmtpClient(“smtp.gmail.com”, 587)
{

Credentials = new NetworkCredential(“EmailAccountUserName@gmail.com”, “Password”),
EnableSsl = true;

};

client.Send(“EmailAccountUserName@gmail.com”, “EmailAccountUserName@gmail.com”, “EmailSubject”, “EmailBody”);

}

I hope you will find this useful…

I hope