无法使用System.Net.Mail发送电子邮件

时间:2019-05-05 11:44:15

标签: c# email smtp

我目前正在尝试将电子邮件从应用程序发送到我的电子邮件地址。 每当我尝试执行应用程序时,都会收到错误消息:

IOException:无法从传输连接net_io_connectionclosed读取任何数据。

        MailMessage message = new MailMessage();
        SmtpClient smtp = new SmtpClient();
        smtp.Port = 465;
        smtp.Host = "mail.gmx.com";                 
        smtp.UseDefaultCredentials = false;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        message.From = new MailAddress("something@something.com");
        message.To.Add(new MailAddress("test.test@gmx.com"));
        message.Subject = cbx_SubjectEmail.Text;
        message.Body = txt_EmailText.Text;
        smtp.Send(message);

0 个答案:

没有答案