我尝试使用此代码发送电子邮件..但smtp.Send(mail)发生错误;消息“发送邮件失败”
MailMessage mail = new MailMessage();
// set the addresses
mail.From = new MailAddress("from@gmail.com");
mail.To.Add(new MailAddress("to@yahoo.com"));
// set the content
mail.Subject = "test sample";
mail.Body = @"thank you";
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.Credentials = new NetworkCredential("from@gmail.com", "password");
smtp.Send(mail);