In my c# web app, I have a bunch of aspx pages that I want to add error catching, try catch and finally code and anytime the catch exception is invoked I want to call a common function(send an email) I have in my helper.cs file - code below.
The problem is I dont know how to access this function that is in my class, the helper file from my aspx.cs file. I dont want to copy this code accross all my aspx.cs file.
Assistance would be appreciated.
public void SendEmailOpen( string strSubject, string strContent, string strTo, string strCc )
//send email to the admins - get admin list from web.config
MailMessage mail = new MailMessage();
mail.From = ConfigurationSettings.AppSettings["email_from"];
mail.Subject = strSubject;
mail.Body = strContent;
mail.BodyFormat = MailFormat.Html;
mail.Priority = MailPriority.High;
mail.To = strTo;
mail.Cc = strCc;
SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["email_server"];
catch (Exception ex)
while( ex.InnerException != null )
ex = ex.InnerException;