var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("my email", "my password")
};
我经常收到 System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission.
这段代码是否必须在某些特殊的托管环境中使用,或者我是否遗漏了一些明显的东西?
谢谢!