Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error sending email

Error sending email

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netmysqlcomsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dot Net Dev
    wrote on last edited by
    #1

    Hi, I have designed ASP.NET C# 3.5 (MySQL) website and it is hosted on shared web server. I have to send email to site users. I have written the all required code, I am sending mail from "info@mysitename.com" to yahoo or gmail but having the following exception. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Line 41: objEmail.Priority = MailPriority.Normal; Line 42: Line 43: SmtpClient smtpClient = new SmtpClient(smtpServer, Convert.ToInt32(port)); Line 44: System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(fromAddress, pwd); Line 45: Thanks

    S 1 Reply Last reply
    0
    • D Dot Net Dev

      Hi, I have designed ASP.NET C# 3.5 (MySQL) website and it is hosted on shared web server. I have to send email to site users. I have written the all required code, I am sending mail from "info@mysitename.com" to yahoo or gmail but having the following exception. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. Line 41: objEmail.Priority = MailPriority.Normal; Line 42: Line 43: SmtpClient smtpClient = new SmtpClient(smtpServer, Convert.ToInt32(port)); Line 44: System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(fromAddress, pwd); Line 45: Thanks

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Dot-Net-Dev wrote:

      ine 43: SmtpClient smtpClient = new SmtpClient(smtpServer, Convert.ToInt32(port)); Line 44:

      Everything is pretty self explanatory. The port that you are trying to use to send emails is blocked by your IT team. You need to talk to them and get it unblocked. Further make sure you have configured SMTP configuration in Web.Config:

      <system.net>
      <mailSettings>
      <smtp from="abc@somedomain.com">
      <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
      </smtp>
      </mailSettings>
      </system.net>

      If needed, have a look at this Microsoft Video tutorial: Use ASP.NET to Send Email from a Web Site [^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups