请求类型为"System.Net.Mail.SmtpPermission"的权限失败. [英] Request for the permission of type 'System.Net.Mail.SmtpPermission' failed.

查看:179
本文介绍了请求类型为"System.Net.Mail.SmtpPermission"的权限失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Request for the permission of type ''System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' failed.

代码是:

Request for the permission of type ''System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' failed.

Code is:

protected void BtnSend_Click(object sender, EventArgs e)
    {
        try
        {
            MailMessage MM = new MailMessage(TxtFAddress.Text, TxtToAddress.Text, TxtSubject.Text, TxtMatter.Text);
            MM.IsBodyHtml = false;
            NetworkCredential Nc = new NetworkCredential(TxtFAddress.Text, "kattalavan0303");
            SmtpClient Sc = new SmtpClient("smtp.gmail.com", 587);
            Sc.UseDefaultCredentials = false;
            Sc.Credentials = Nc;
            Sc.EnableSsl = true;
            Sc.Send(MM);
            lblDisplay.Text = "Mail Delivered sucessfully";
        }
        catch (Exception ex)
        {
            lblDisplay.Text = ex.Message;
        }
    }

推荐答案

您是否已将应用安全性配置为具有足够的信任度?

如果这是ASP.NET Web应用程序的一部分,那么您是在自己的开发/测试计算机还是公共Web服务器上运行?如果是后者,则您可能需要要求托管公司给予您的应用程序完全(或至少更高)的信任,因为您可能无法自己覆盖它们的默认信任设置(出于明显的原因!).
Have you configured your app security to have sufficient trust?

If this is part of an ASP.NET web app, are you running on your own development / test machine or a public web server? If the latter you may need to ask your hosting company to give your app full (or at least greater) trust as you probably can''t override their default trust settings yourself (for obvious reasons!).


您是否已通过Google搜索错误消息?这是
Have you Googled for the error message? Here is the search result[^]

5690 results, isn''t that amazing?

So in future do search before you ask. :thumbsup:


这篇关于请求类型为"System.Net.Mail.SmtpPermission"的权限失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆