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