我尝试使用以下代码发送邮件:
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("mailserver");
mail.From = new MailAddress("mailid");
mail.To.Add("mailid");
mail.Subject = "Test";
mail.Body = "Report";
//Console.WriteLine(SmtpServer.Port +"......"+ SmtpServer.Host);
SmtpServer.Port = 465;
SmtpServer.Credentials = new System.Net.NetworkCredential("mailid", "pwd");
SmtpServer.EnableSsl = true;
SmtpServer.Timeout = 40000;
SmtpServer.Send(mail);
例外:
端口号的操作超时465端口,适用于港口号码。 587