0
我在發送郵件時遇到問題。我的代碼非常簡單,如下所示。 代碼啓動時,它提供了錯誤:發送郵件時出錯vb.net
Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
當我搜索這個錯誤,他們建議改變的web.config充分的信任設置或端口從587到25和其他的東西,但沒有工作。它還能是什麼?
Sub MailGonder()
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Host = "mail.excelinefendisi.com"
SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "mypassword")
SmtpServer.Port = 587
mail.From = New MailAddress("[email protected]")
mail.To.Add("[email protected]")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP"
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
End Sub
請註明完整例外。 –
請求'System.Net.Mail.SmtpPermission,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'類型的權限失敗。 – ExcelinEfendisi