如何修复SmtpClient.ServicePoint-引发了类型为'System.NotSupportedException'的异常

时间:2019-04-04 00:58:30

标签: asp.net webforms visual-studio-2017 smtpclient servicepoint

我正在尝试通过下面的代码发送电子邮件,但服务点出现异常。我正在使用System.Net和System.Net.Mail;

objEmail.To.Add("client@mysite.com);
objEmail.Priority = MailPriority.Normal;          
objEmail.IsBodyHtml = true;    
objEmail.Subject = "test send e-mail";
objEmail.Body = "message...";
objEmail.SubjectEncoding = Encoding.GetEncoding("ISO-8859-1");
objEmail.BodyEncoding = Encoding.GetEncoding("ISO-8859-1");
SmtpClient objSmtp = new SmtpClient("mail.mysite.com")
{
   Credentials = new NetworkCredential("awards@mysite.com", "myPassword"),
   EnableSsl = true,
   Port = 25
};
objSmtp.Send(objEmail);

我收到“引发了类型为System.NotSupportedException的异常”。

0 个答案:

没有答案