asp website error email problem

Incubus

New Member
Hi, I'm currently working through a book for creating an e-commerice site but have run in to a problem. I have put in error logging, which works fine, but their section for writing the error email notification isn't making sense to me.

Here is the code they have:

// Generic method for sending emails
public static void SendMail(string from, string to, string subject,
string body)
{
// Configure mail client (may need additional
// code for authenticated SMTP servers)
SmtpClient mailClient = new SmtpClient
(BalloonShopConfiguration.MailServer);
// Create the mail message
MailMessage mailMessage = new MailMessage(from, to, subject, body);
/*
// For SMTP servers that require authentication
message.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
message.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername",
"SmtpHostUserName");
message.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"SmtpHostPassword");
*/
// Send mail
mailClient.Send(mailMessage);
}
// Send error log mail
public static void LogError(Exception ex)
{
// get the current date and time
string dateTime = DateTime.Now.ToLongDateString() + ", at "
+ DateTime.Now.ToShortTimeString();
// stores the error message
string errorMessage = "Exception generated on " + dateTime;
// obtain the page that generated the error
System.Web.HttpContext context = System.Web.HttpContext.Current;
errorMessage += "\n\n Page location: " + context.Request.RawUrl;
// build the error message
errorMessage += "\n\n Message: " + ex.Message;
errorMessage += "\n\n Source: " + ex.Source;
errorMessage += "\n\n Method: " + ex.TargetSite;
errorMessage += "\n\n Stack Trace: \n\n" + ex.StackTrace;
// send error email in case the option is activated in Web.Config
if (BalloonShopConfiguration.EnableErrorLogEmail)
{
string from = "[email protected]";
string to = BalloonShopConfiguration.ErrorLogEmail;
string subject = BalloonShopConfiguration.SiteName + " error report";
string body = errorMessage;
SendMail(from, to, subject, body);
}
}
}

I don't have a clue how to link this with a real email account!
 

zkiller

Super Moderator
Staff member
don't see to many people choosing javascript to write there asp pages in. vbscript is pretty much the standard. that being said, i have no clue. me and javascript don't get along very well. it doesn't like me and i don't like it.

you might want to try posting this over at www.sitepointforums.com, if you don't find the help you need here.

good luck.
 
Top