一段用jmail发邮件的代码出错,请各位帮忙。
出错信息:
安全性异常
说明: 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。
异常详细信息: System.Security.SecurityException: System.Security.Permissions.SecurityPermission
源错误:
行 42: oJmailMessage = Nothing
行 43:
行 44: End sub
行 45: </script>
行 46: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN " >
源文件: d:\inetpub\wwwroot\JmailSend.aspx 行: 44
代码如下:
<script language= "VB " runat= "server ">
Sub bts(sender as object,e as system.eventargs)
Dim oJmailMessage As New jmail.MessageClass()
oJmailMessage.Charset = "GB2312 "
oJmailMessage.Encoding = "BASE64 "
oJmailMessage.ContentType = "text/html "
oJmailMessage.ISOEncodeHeaders = False
oJmailMessage.Priority = Convert.ToByte(1)
oJmailMessage.From = TxtEmail.Text.Trim()
oJmailMessage.FromName = TxtName.Text.Trim()
oJmailMessage.Subject = txtSubject.Text.Trim()
oJmailMessage.MailServerUserName = TxtSmtpUser.Text.Trim()
oJmailMessage.MailServerPassWord = TxtSmtpPwd.Text.Trim()
oJmailMessage.AddRecipient(txtReciver.Text.Trim(), " ", " ")
If " " <> upFile.PostedFile.FileName Then
Dim attpath As String = upFile.PostedFile.FileName
oJmailMessage.AddAttachment(attpath, True, attpath.Substring(attpath.LastIndexOf( ". ") + 1, 3))
End If
oJmailMessage.Body = txtContent.Text.Trim()
If oJmailMessage.Send(TxtSmtServer.Text.Trim(), False) Then
Response.Write( "发送成功! ")
Else
Response.Write( "发送失败,请检查邮件服务器的设置! ")
End If
oJmailMessage = Nothing
End sub
</script>
------解决方案--------------------I can not find any error from your code, if you can, please catch the exception and show it to us.