How to send an email using Gmail and c#

How you can sent an email in c # using Gmail's SMTP servers. The only trick here is that Gmail requires you  to use port 587, enable SSL and supply valid login details.

            var client = new SmtpClient("smtp.gmail.com"587)
            {
                Credentials = new NetworkCredential("[valid Gmail username]""[valid Gmail password]"),
                EnableSsl = true
            };
            client.Send("[email from address]""[email to addression]""[email subject]""[email body]");

No comments:

Post a Comment