This post was original posted on my personal site in October 2007, but it's a better fit here and since it gets a bunch of visits every day I figured it'd be better to move it than kill it. Enjoy, updates at the bottom.
Which is a lot cleaner, and I never did get around to writing about lambda abuse, but seriously, it's cool stuff. The best way to learn how to refactor old C# code, in my opinion, is to get a copy of Resharper, which will make all kinds of suggestions. Your old code will get cleaner, and you'll be a faster programmer – obviously don't go around refactoring everything blindly in a release that's just supposed to have a spelling mistake fixed in it, but make the changes when test windows present themselves, and then just code in your old style and let Resharper help you get up to speed.
And maybe it even works. Until you switch to or do your initial deploy to a new Windows 2008 server. And you get the dreaded "cannot get IIS pickup directory" error.
Now, I regularly call myself the world's most dangerous system administrator. It's not what I do. I'm not especially good at it, but sometimes I need to get in there and do stuff so I can get paid for my actual work. The rest of this post is a starter checklist on things to look into if you're getting this error. If you have further questions, I probably won't be able to help you, so I apologize in advance. If you manage to find answers for your further questions, it'd be awesome if you could share them in the comments so other people can gain more value – one of the reasons I'm writing this up on a Saturday when I'd love to be with my family is because it took me an hour to solve this, even though I'd solved the problem once before, and not too long ago. There aren't a lot of good solution guides online, so let's work together to build one!
Also, securing your SMTP server is a whole other post, and the balance between sending directly from your web server and using a dedicated service, deliverability, and other email issues are separate from this post. Boom. Now let's get on with it.
Your web server might not even have the SMTP service installed, so get into the server manager and make sure that's in the feature list. If it's not, you'll need to add it.
After that, you'll want to play with the SMTP server settings – I don't know a lot about these, to be honest, so I'm not going to get into them, but you need to know that SMTP is still part of IIS 6.0, so you'll find it in the IIS 6.0 Manager. One quick tip though, because it might get missed – some receiving servers require a fully qualified domain name, and your server might have a name like "Server15" or something, which isn't fully qualified, so in the SMTP properties, under the Delivery tab, click the Advanced button and put a real hostname in the fully qualified domain name field.
3) Is the firewall open?
Then hit enter, period, enter to finish the mail.
If you can't connect, or the mail doesn't arrive, there's something else wrong that you'll need to fix, because it doesn't matter if the pickup directory's available.
4) Does IIS have access to the metabase?
Here's where we get to the actual problem – chances are, the process that runs your website doesn't have access to the IIS metabase that stores the name of the pickup directory, and this is the general cause of your error.
5) Does IIS have access to the pickup directory?
That's more or less what it took to get things running for me, but as with any server troubleshooting, it's possible that I clicked some magic checkbox somewhere along the way that's also key to the process, so if you have questions, post 'em in the comments, and if you know the answer to one of those questions, because as I said, I likely don't, then post that as well and I'll do my best to incorporate that data into the core post.