Emails are the important part of any web application to make an interaction between website and end users. I got many queries from my friends for “How to send emails in ASP.NET”, so I have created a sample email sending application in asp.net to give you an idea about email sending in asp.net. So take a look at the how to make an application which will send emails.
First of all setup your mail server settings in web.config file, so that you’ll need not to define the mail server settings every time in code. In the web.config file define the <system.net> tag to define the mail server settings as below:
<!–Mail Server–>
<system.net>
<mailSettings>
<smtp deliveryMethod=”Network”>
<network host=”your host name” port=”25″ userName=”" password=”" defaultCredentials=”false”/>
</smtp>
</mailSettings>
</system.net>
In the above settings change your host name in <network> tag. Port number usually default 25, but it depends on your mail server settings, add you username and password for mail server.
After setting up your mail server settings in web.config file, create a page from where you want to send emails. I have created default.aspx page from where I’ll send emails. In this page I have created a sample interface for sending emails, with some common fields, from, to, subject, and body of email with a Send Mail button. On click of the button I am executing the following code.
if (sendMail(txtfrom.Text, txtto.Text, txtsubject.Text, txtbody.Text))
{
lblmsg.Text = “Mail Sent”;
}
else
{
lblmsg.Text = “Some error has been occured, please try again!”;
}
In the above code I am executing a sendmail function in if condition, sendmail function returns a bool type (true or false) value. If emails sent successfully then it will return true else return false. On the basis of that bool value returned by the sendmail function I am displaying the error message if email sending is failed. Sendmail function is defined in this default.aspx file, just download the sample app below and look by yourself, if have any problem please comment below.
This is a simple mail sending application with minimal options you can also use CC, BCC, attachments etc, just explore more options from this (http://www.systemnetmail.com/) site which is specially made for describing the email sending method and function in ASP.NET 2.0.
Download the sample application here: DOWNLOAD

[...] See the original post here: ASP.NET – How to send email in asp.net 2.0 « Tech Ahead [...]
[...] the original here: ASP.NET – How to send email in asp.net 2.0 « Tech Ahead SHARETHIS.addEntry({ title: "ASP.NET – How to send email in asp.net 2.0 « Tech Ahead", url: [...]
Dear Friends,
I hope you are doing well. I have launched a web site http://www.codegain.com and it is basically aimed C#,JAVA,VB.NET,ASP.NET,AJAX,Sql Server,Oracle,WPF,WCF and etc resources, programming help, articles, code snippet, video demonstrations and problems solving support. I would like to invite you as an author and a supporter. Looking forward to hearing from you and hope you will join with us soon.
Please forward this email to all of your friends who are related IT. Send to us your feed about site also.
Thank you
RRaveen
Founder CodeGain.com