2013-07-28

Hi Friend,Today I am going to show you "How to send mail from ASP.NET Application".You can easily send the mail through your gmail account or other account to another account (  yahoo ,outlook, reddiffmail etc).In this application you can easily send mail without opening your gmail account or other account.First i will used a simple ASP.NET Application for  sending the mail. After that i will tell you how to use this mail service in our ASP.NET Website . It is secure because you are sending the mail through gmail account or other account.In this application ASP.NET 's Variable (object) holds your credential Information and pass to your mail service provider.When your mail server will validate then your message will be delivered successfully to the correct destination.

There are some steps to make this application which are given below:
Step 1:First open your visual studio --> File -->New -->ASP.NET Empty website --> open your solution Explorer -->Add a New Web Form -->Drag and drop Label, Button and TextBox Control on the Web Form as shown below:



Step 2: Now Double click on Send Button and Write the following codes which are  given below:

Description:- In above example,First i have include two Namespace to use the mail service in ASP.NET Application.

using System.Net.Mail;

using System.Net;

After that i have created a Smtpclient class object (smtpc) and passed the Smtp server name and port Number  to the Smtpclient. After that  i have passed the our credential information to the Network through Smtpclient object(smtpc). After that i have created a MailMessage class object(email) and passed sender mail address,  destination mail address,subject,message body to the MailMessage class. After that send the mail message through Smtpclient object(smtpc) as shown in  above codes.

Step 3: Now Run the Program (press F5)-->Fill the required fields as shown below -->press Send button.
Output:


Step 4: Now Open Your Mail Box (destination) ,you will see that your mail has received in mail Box  successfully as shown below:



Step 5: If you will Enter incorrect ID or password then this Application will give an Error message on the screen as sown below:

How to use Above Email service in ASP.NET Registration Page
You will have to seen that many website are using mail service on your website.When any user does register  on the website then website automatically send a mail to your email address.In tutorial ,i will show you how to a send mail ,when any user will register on your website.For implementation of this concept ,i will use our Previous Registration Page 
There are some steps to implement mail service in ASP.NET website.which are given below:
 Step 1: First open your visual studio --> File -->New -->ASP.NET Empty website --> open your solution Explorer -->Add a New Web Form -->Drag and drop Label, Button and TextBox ,Validation Control on the Web Form as shown below:

 Step 2: Now Double click on Submit Button and Write the following codes which are give below:

Step 3: Now Run the Application (Press F5)-->Fill the required control  fields as shown below:

Step 4: Now Click Submit Button.
Output:

Step 5: Now open your Email Box.You will see as shown below:

Note:- Here I have used a gmail mail service  because it is free and secure.Every person can implement this Email service on your ASP.NET Website free.If you have own mail server then you can use your mail server instead of gmail server.You will have to seen that all website on internet use your own mail server for sending the mail.
For More:-

How to solve SQL Server problem

Create setup file with Database

Web Form controls

File Handling Real Application

oops concepts

I hope this is helpful for you.

To Get the Latest  Free Updates Subscribe
Click below for Download whole Application
             Download

Show more