I’ve stubbed my toe on this a couple of times, so here is the magic incantation:
using (SmtpClient smtp = new SmtpClient())
{
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new NetworkCredential("email@gmail.com", "password");
// send the email
}