Is it possible to send email from my computer(localhost) using asp.net project in C#? Finally I am going to upload my project into webserver but I want to test it before upl
Your code above should work fine, but you need to add the following to your web.config (as an alternative to any code-based SMTP configuration):
If you don't have access to a remote SMTP server (I use my own POP3 / SMTP email details), you can set up an SMTP server in your local IIS instance, but you may run in to issues with relaying (as most ISP consumer IP addresses are black listed).
A good alternative, if you don't have access to an SMTP server, is to use the following settings instead of the above:
This will create a hard disk copy of the email, which is pretty handy. You will need to create the directory you specify above, otherwise you will receive an error when trying to send email.
You can configure these details in code as per other answers here (by configuring the properties on the SmtpClient object you have created), but unless you're getting the information from a data source, or the information is dynamic, it's superfluous coding, when .Net already does this for you.