Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 8th, 2016, 05:39 PM
Authorized User
 
Join Date: Dec 2015
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Default Exception Handling - Email Notiification

This is posted as a hint to anyone having trouble with sending the email message for an exceptions as outlined in Chapter 18.

For me, the code in the book worked perfectly on my local machine but when I deployed to my web host (MyindowsHosting.com) I could not get it to send the "exception emails" The code for the login response and contact response did work on the web site. I spent about a week trying to figure out how to get the "exception e-mail" to work and finally, out of desperation, tried the following:

I changed the code in the Global.asax module as follows:

1) Added <%@ Import Namespace="System.Net"%>

2) Made the following change in the Application_Error Handler:

Removed the following two statements:

// SmtpClient mySmtpClient = new SmtpClient();
// SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587);

And replaced withthe following (The same code as in the Controls.
ContactForm.asax.cs)

// Required to change the code in "Beginning Asp.Net 4.5.1 in C# and VB"
// to the following in order for it to send mail on My WindowsHosting Site1

SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587);
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = new
NetworkCredential("[email protected]", "*******");
mySmtpClient.EnableSsl = true;
mySmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mySmtpClient.Send(myMessage);

This worked for me and I hope this hint may help someone else out.
The Following User Says Thank You to trtyler For This Useful Post:
Imar (August 13th, 2016)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception Handling Fed BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 February 16th, 2010 05:49 PM
Exception handling codehelp C# 2008 aka C# 3.0 4 August 27th, 2009 07:46 AM
exception handling jay schumacher VB.NET 2002/2003 Basics 1 April 14th, 2006 08:40 AM
Exception handling aldwinenriquez General .NET 0 August 17th, 2005 06:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.