无法通过IIS服务器发送电子邮件(在本地工作)

时间:2017-06-14 14:10:40

标签: c# .net vba smtp

我几个月来一直在努力,请有人帮我解决这个问题。谢谢

 try
        {
            SmtpClient smtpServer = new SmtpClient();
            MailMessage mail = new MailMessage();
            smtpServer.Credentials = new System.Net.NetworkCredential("iejabdb@otlook.com", "throughput");
            smtpServer.Port = 25;
            smtpServer.Host = "*****";
            smtpServer.EnableSsl = true;
            smtpServer.UseDefaultCredentials = true;
            mail.From = new MailAddress("*****@outlook.com", "Work Order System");
            mail.To.Add("*******@outlook.com");
            // mail.To.Add(receiptsArray.ToString());
            mail.Subject = "Test";
            mail.Body = "Hello";
            smtpServer.Send(mail);
        }

1 个答案:

答案 0 :(得分:0)

测试此代码:

        MailMessage mail = new MailMessage();
        SmtpClient SmtpServer = new SmtpClient("smtp.live.com");

        mail.From = new MailAddress("mawlud.f.m@hotmail.com");
        mail.To.Add("mawlud.f.m@gmail.com");

        mail.Subject = "Mail Subject";
        mail.Body = "Mail Body";

        SmtpServer.Port = 587;
        SmtpServer.Credentials = new System.Net.NetworkCredential("mawlud.f.m@hotmail.com", "Write Your Password");

        SmtpServer.EnableSsl = true;
        SmtpServer.Send(mail);