网络更改后C#SMTP电子邮件不起作用

时间:2018-08-16 08:13:15

标签: c# smtpclient

我当时正在处理在家发送的smtp电子邮件,可以正常发送成功的电子邮件,但是在尝试工作时,浏览器开始加载,大约4分钟后,电子邮件无法发送。

    public void sendEmail()
    {
        try
        {
            MailMessage mM = new MailMessage();
            mM.From = new MailAddress("myemail@outlook.com");
            mM.To.Add(lblmail.Text);
            mM.Subject = "Your leave plan -- (do not reply)";
            mM.Body = "Your application for " + ddlleavetype.Text + ddlleavetype2.Text + " on " + txthalfdate.Text + txtsingledate.Text + " has been auto approved. If you have any queries please reach out to " + lbltm.Text;
            mM.IsBodyHtml = true;
            SmtpClient sC = new SmtpClient("smtp.live.com");
            sC.Port = 25;
            sC.Credentials = new NetworkCredential("myemail@outlook.com", "myemailpwd");
            sC.EnableSsl = true;
            sC.Send(mM);
        }
        catch (Exception ex)
        {
            lblmsg2.Text = "Failed to send email!";
        }
   }

我在这里想念什么?预先感谢。

0 个答案:

没有答案