【发布时间】:2015-08-20 13:35:29
【问题描述】:
我一直在做一个涉及发送电子邮件的项目,我终于让它工作了,但是几天不使用我的系统后,我尝试再次运行代码,我得到“无法连接到远程服务器”错误。
请任何人帮我检查一下代码,我已经用了一个多星期了。
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("***@gmail.com");
mail.To.Add("******@gmail.com");
mail.Subject = "Test";
mail.Body = ("the mdfjvnloifvhsuifv");
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("***@gmail.com", "pwd");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
Label1.Text = "MAIL SENT!!!";
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
//throw;
}
【问题讨论】:
标签: c# server connect smtpclient