我复制该代码 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”