I see this question asked over and over in the ASP.NET forums and many times the answer is you have to have an SMTP server on your local machine. The person asking the question is usually under the wrong impression that setting the SMTP server property to localhost is all they need to do and e-mail will magically be sent from their web server.
Back in July I introduced you to Neptune, a local SMTP server for testing. If you are developing this is a great tool to use to test e-mail functionality while you are developing. But this still does not explain what that SMTPServer property is all about. This is where you can either pass the IP address or the fully qualified domain of the SMTP server you can use to send e-mail.
When you configure your e-mail client, think MS Outlook, you have to provide both a POP and SMTP server. You can't just send e-mail from your own machine, unless you have an SMTP server running on your local machine. The SMTP protocol is defined in a series of RFCs. You can read more about SMTP on Wikipedia if you want.
But here is the reality, you cannot just send e-mail from .NET without having an SMTP server to actually send the message. A server can be anything from a simple tool like Neptune up to a full blown server like Exchange. In between you can install the SMTP server that ships with IIS 6.0 or many other SMTP servers. But you need to be aware of how to secure them to safeguard them from being compromised by Spammers. Even inside your company's firewalls or at home, your ISP and system admins may only allow you to use an authorized mail server. So do check with them for the address you need to use.
So the next time you get an error, 'Cannot connect to SMTP server', ask if you actually have an SMTP server to connect to. If not find the one you can use.