- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Who wants to bet there were multiple people who set up rules to automatically move any exception-mails to recycling?
Admin
And of course, the
SmtpClient
would need to be.Dispose
d, but isn't ...Edit Admin
I can definitely see the compiler doing a tail recursion optimisation and preventing a StackOverflowException from ever happening, but in that case it just becomes an infinite loop that hangs the thread, but might unexpectedly end if the problem that causes the failure of SendEMail is resolved.
(In reality, it might well end sooner than that, as in, for example, the process running out of memory for allocating another
SmtpClient
object.)Admin
If I had a penny for every time a manager had said that IT should send out an email to let people know that email was down, I'd probably have enough to buy a chocolate bar. Joined up thinking seems to be sadly lacking for a lot of people.
Edit Admin
Bonus points for not using the
receivers
parameter.Edit Admin
At a previous job, a certain web service application sent out an email to the ops team every time the server served up an HTTP 500 error with the exception stack trace and details etc. That worked ok at first, but then the first time someone pushed a bug that broke 100% of all requests...well let's just the email server wasn't too happy, and we very quickly added some rate limiting to the email sending.
Edit Admin
I worked for a company once that failed to send more than 80% of emails successfully, and called it industry standard. Using email to alert people is unlikely to work, either no one sees the email because they are asleep, or so many emails are sent than they filter them all out.
Edit Admin
.NET's JIT doesn't do tail call optimization. And if it did in the future, it won't apply here because (1) there's a SEH block (the try/catch), and (2) this is probably the old .NET Framework which had a very weak JIT.
Edit Admin
OK, fair enough. Thanks for the extra info. In that case, it becomes a race between running out of stack for the recursion and running out of memory for more SmtpClient objects. These days, it seems highly likely that the stack runs out first, but...
Edit Admin
No recursion.
In .NET, an unhandled exception in a catch block will crash the program.
Or throw it back up one level in the call stack.
I forget which...
Admin
Been there, done that. Cleaning up that mailbox was quite a chore as Outlook/Exchange at that time could handle deletion of just a few 1000 at a time.
Admin
Crashed mail server. Haven't heard on one in the past 20 years.
Edit Admin
I confess that when I was young (i.e. a long time ago) my 404 Not Found error pages would typically include functionality to send me an email depending on the referrer header. Even then I knew you have zero control on external links, but I was apparently very concerned of broken internal links slipping into the mostly static sites I built back then.
Edit Admin
Yes, but in this case, the SmtpClient's exception inside the recursive call is handled inside the recursive call. Unless try blocks aren't allowed inside catch blocks...
Edit Admin
I supported a couple of .NET apps that sent an email when an exception occurred. Fortunately it wasn't too often, but the developers (well before my arrival) decided what was really needed in that email was the Session State field. If you've never seen a .NET session state, imagine a block of what looks like Base64 encoded text filling the screen, only worse. Of course, the FTW is that Session State is encoded. Boy, was that ever useful!
Admin
Remi: " Easy Reader Version: I hate email, mostly because the signal-to-noise ratio, even in my work inbox that only co-workers (or services I'm required to use) send messages to is just terrible. 80-85% of the email I receive is useless to me. "
You think that's bad, try being in a Teams group chat!