发送电子邮件时遇到异常

时间:2012-07-21 23:57:23

标签: asp.net

我复制该代码 MailMessage mail = new MailMessage();

        mail.To.Add(model.To);

        mail.From = new MailAddress("sheikh.abm@gmail.com");


        mail.Subject = model.Subject ;

        mail.Body = model.Message;

        mail.IsBodyHtml = true;

        SmtpClient client = new SmtpClient("localhost:");
        client.UseDefaultCredentials = false;
        client.EnableSsl = true;
        client.Host = "localhost:";
        client.Port = 25;

        NetworkCredential credentials = new NetworkCredential(model.To, "abc");

        client.Credentials = credentials;

        try
        {
            client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
            client.Send(mail);
        }
        catch
        {



        }
        return View("Index");
    }

我得到的例外是“不能为启用目录的传送方法启用SSL”

0 个答案:

没有答案