Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi
i have 1 web site

if any error raises while running the application on the web suddenly i just want to

send that error message (execption) to few mail ids

as email notification

can anyone help me

thank u
Posted
Comments
Ed Nutting 3-Dec-11 11:51am    
Try searching CP for "Send email" with what ever language tags you want. There are many articles/tiptricks on the subject.

C#
try
{



}
catch (Exception ex)
{
   // use ex as body for email
   // Please study SMTP, google it so you'll learn how to google :-)
}


Regards,
Eduard
 
Share this answer
 
To catch the errors anywhere in your site, do the following. Add the following lines in your Global.asax file within Application_Error.
C#
void Application_Error(object sender, EventArgs e)
{
    // Code that runs when an unhandled error occurs
    Exception objErr = Server.GetLastError().GetBaseException();
    string err = "Error in: " + Request.Url.ToString() +
                      ". Error Message:" + objErr.Message.ToString();
    //send email here

}


I didn't implement the email sending in the above code. Please refer to the following link for how to send email.
Send email links

Feel free to contact for further information.
 
Share this answer
 
Comments
Srinivas Kumar Pasumarthi 20-Dec-11 1:16am    
thanks a lot
Monjurul Habib 20-Dec-11 11:39am    
pleasure :) please mark as answer accepted if this post solve your problem.
where is ur code ?if u given code means easily to solve an error.
 
Share this answer
 
Comments
Monjurul Habib 4-Dec-11 1:28am    
this can be your comment not an answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900