i have used the following code and getting the mail when error in application but i also get the mail when the page is running fine. if there is no image found in local server then it also send. The code is given below
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception objError = Server.GetLastError().GetBaseException();
string error = " <br/><br/>Error in: <b>" + Request.Url.ToString() +
" <br/><br/> IP Address:"+ HttpContext.Current.Request.UserHostAddress +
" <br/><br/>Error message:" + objError.Message.ToString() +
" <br/><b/>Stack Trace: <b/><br/>" + objError.StackTrace.ToString();
SmtpClient smtclient = new SmtpClient();
MailMessage msg = new MailMessage();
MailAddress fromAddress = new MailAddress("noreply@abc.com", "www.abc.com");
msg.From = fromAddress;
msg.To.Add("mdikram0530@gmail.com");
msg.Subject = "Error in the Website";
msg.Priority = MailPriority.High;
msg.Body = error;
msg.IsBodyHtml =false;
smtclient.Host = "mail.abc.com";
smtclient.Credentials = new System.Net.NetworkCredential("test@abc.com", "123456");
smtclient.Send(msg);
}