我在尝试发送邮件时遇到问题。VS 给我一个这个错误:发送邮件失败。我做错了什么!!
string from = "from@htomail.com";
string to = "to@gmail.com";
MailMessage mail = new MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "test", System.Text.Encoding.UTF8);
mail.Subject = "testing";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "Loren ipsum";
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new System.Net.NetworkCredential(from, "password");
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.Send(mail);