繁体   English   中英

当我尝试通过SmtpClient.Send方法发送电子邮件时,为什么会抛出异常?

[英]Why it is throwing an exception when I am trying to send an email by SmtpClient.Send method?

我想通过C#创建一个电子邮件发件人。 我使用System.Net.Mail来做到这一点。 但是在我使用SmtpClientSend()方法Send()邮件之后做了所有的事情,它会抛出异常。 为什么?

代码在这里

MailMessage mail = new MailMessage("wtushar_09@live.com", "wtushar09@gmail.com");
SmtpClient sc = new SmtpClient("smpt.live.com");
sc.Port = 587;
sc.Credentials = new System.Net.NetworkCredential("wtushar_09@live.com", "************");
sc.EnableSsl = true;
sc.Send(mail);
MessageBox.Show("Mail sent", "done", MessageBoxButtons.OK);

异常来自sc.Send(mail);

SmtpClient sc = new SmtpClient("smpt.live.com");

您的SMTP服务器名称可能有误。 应该是smtp.live.com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM