P
paul downing via DotNetMonster.com
global file email send
--------------------------------------------------------------------------------
guys, i'm developing an application and want to send an email with an error if it occurs to the administrator... i tried the following below but can't get it working.
I did have it working a while ago...but have had no success with this.... any ideas?
heres the code (simplistic) from the global.asax file:
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.text" %>
<%@ Import Namespace="System.web" %>
<%@ Import Namespace="System.web.sessionstate" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Text" %>
<script language="VB" runat="server">
Public Class Global
Inherits System.Web.HttpApplication
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim mail As New MailMessage()
Dim ErrorMessage = "The error description is as follows : " & Server.GetLastError.ToString
mail.To = "(e-mail address removed)"
mail.Subject = "Error in the Site"
mail.Priority = MailPriority.High
mail.BodyFormat = MailFormat.Text
mail.Body = ErrorMessage
SmtpMail.Send(mail)
End Sub
End Class
i have even tried a simple reponse.write in the application_error and can't seem to make it trigger! Can someone point me in the right direction?
thanks
--------------------------------------------------------------------------------
guys, i'm developing an application and want to send an email with an error if it occurs to the administrator... i tried the following below but can't get it working.
I did have it working a while ago...but have had no success with this.... any ideas?
heres the code (simplistic) from the global.asax file:
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.text" %>
<%@ Import Namespace="System.web" %>
<%@ Import Namespace="System.web.sessionstate" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Text" %>
<script language="VB" runat="server">
Public Class Global
Inherits System.Web.HttpApplication
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim mail As New MailMessage()
Dim ErrorMessage = "The error description is as follows : " & Server.GetLastError.ToString
mail.To = "(e-mail address removed)"
mail.Subject = "Error in the Site"
mail.Priority = MailPriority.High
mail.BodyFormat = MailFormat.Text
mail.Body = ErrorMessage
SmtpMail.Send(mail)
End Sub
End Class
i have even tried a simple reponse.write in the application_error and can't seem to make it trigger! Can someone point me in the right direction?
thanks