我正在使用以下非常简单的代码,但System.Net.Mail.SmtpException
发送邮件一直失败。这是我的代码:
static void main(string[] args)
{
MailAddress from = new MailAddress("MyEmail@gmail.com", "Mr. Test");
MailAddress to = new MailAddress("AnotherEmail@gmail.com", "mr. man");
MailMessage msg = new MailMessage(from, to);
msg.Subject = "email";
msg.Body = "This is email.";
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Send(msg);
}
我以前从未尝试过以编程方式发送电子邮件,所以我很感激帮助。