The code below works for me... I have heard anecdotally that UseDefaulCredentials=false must precees the Credentials line
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout=10000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
try
{
smtp.Send(message);
}
catch (Exception e)
{
MessageBox.Show("Email request failed: " + e.Message);
}
}