Hi, Friends today i am going to make a Forget password Form application,so that any body can get your Forget password on your registered mail from ASP.NET website free. Previously i have made Registration and Login page Application,You can attach this Forget password page in this application.Here I have used gmail SMTP server for sending the User Name and respective password value to the registered email address.You can use your own server instead of gmail server for this purpose.It is full secure because you are sending the mail through gmail SMTP server.But for own Hosting you can use your SMTP server.The Students who are making any project they can use this service free because server space is more costly.
There are some steps to implement this concept in your ASP.NET website.
Step 1:- First open your visual studio --> File --> New -->website -->ASP.NET EMPTY WEBSITE -->OK -->Now open your Solution Explorer -->Add a web Form -->Drag and Drop Label,Text Box and Button controls on the form as shown below:-
Step 2:- Now Add a Database.mdf file for stored the registration value in the website -->Create a emp table -->register some person also as shown below.
Note:- If you are facing any problem to create .mdf file on website,please read below link:-There are some steps to implement this concept in your ASP.NET website.
Step 1:- First open your visual studio --> File --> New -->website -->ASP.NET EMPTY WEBSITE -->OK -->Now open your Solution Explorer -->Add a web Form -->Drag and Drop Label,Text Box and Button controls on the form as shown below:-
Step 2:- Now Add a Database.mdf file for stored the registration value in the website -->Create a emp table -->register some person also as shown below.
Step 3:- Now Double click on Submit button--> and write the following codes.
using System;
using System.Data.SqlClient;
using System.Data;
using System.Net.Mail;
using System.Net;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT username,password FROM emp Where email= '" +TextBox1.Text + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
if (ds.Tables[0].Rows.Count > 0)
{
MailMessage email = new MailMessage();
email.From = new MailAddress(TextBox1.Text); //Enter sender email address
email.To.Add(TextBox1.Text); //Destination Recipient e-mail address.
email.Subject = "Your Forrget Password:";//Subject for your request
email.Body = "Hi,<br/>Your Username is: " + ds.Tables[0].Rows[0]["username"] + "<br/><br/>Your Password is: " + ds.Tables[0].Rows[0]["Password"] + "<br/>";
email.IsBodyHtml = true;
//SMTP SERVER DETAILS
SmtpClient smtpc = new SmtpClient("smtp.gmail.com");
smtpc.Port = 587;
smtpc.UseDefaultCredentials = false;
smtpc.EnableSsl = true;
Label1.Text = "aryas@gmail.com"; //<--Enter your gmail id here
Label2.Text = "94804";//<--Enter gmail password here
//Label3.Text = "msdotnet website"; //Subject for your website
//Label4.Text = "webcome to http://msdotnet.co.in. please share this website to your friends"; //Message body
smtpc.Credentials = new NetworkCredential(Label1.Text, Label2.Text);
smtpc.Send(email);
Label2.Text = "Your password has been sent to your email address";
}
else
{
Label3.Text="This email address is not exist in our Database try again";
}
}
}
Step 4:- Now Run the application(press F5)-->Now Enter your registered Email address in Text Box as shown below -->Press Submit button :-
Step 5:-Now open your Email account(aryasamaj8@gmail.com)-->you will see your user name and password as shown below:-
Note:- Here i have used same email address for sender and receiver .you can change receiver EMAIL address.But Sender email address should be your gmail SMTP or other server SMTP.
Step 6:- Now again Run this application-->and Enter a wrong Email address which is not present in you emp table-->Then you will see following output as shown below:-
For More:-
- How to send mail from asp.net website free
- How to create setup file with database
- How to create captcha image on asp.net website
- How to print gridview data
- Multithreading in c#
- How to host asp.net website free on the server
- How to host asp.net website on IIS Server
- File handling Real Application
- How to create dll file in asp.net Application
Download
hello..
ReplyDeletewhen i am running this application , i am getting following error.pls help...
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
It may be happened due to multiple times wrong password or other things.try it with different id and password.it will work definitely.
DeleteSir i have tried so many times with different id and password but it shows same error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
ReplyDeletesir pls help me.
thank u very much, it helped me a lot nd is working fine
ReplyDeleteI tried this bt am getting this error.... what to do????
ReplyDelete"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required"
using System;
Deleteusing System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.IO;
namespace SchoolManagementSystem
{
public partial class Email : Form
{
public Email()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try {
MailAddress From = new MailAddress("ajitagarwal2010@gmail.com");
MailAddress To = new MailAddress(txtTo.Text);
MailMessage mmsg = new MailMessage(From,To);
mmsg.Subject= txtSubj.Text;
mmsg.Body = txtBody.Text;
Attachment atch = new Attachment(txtattachment.Text);
mmsg.Attachments.Add(atch);
SmtpClient sc = new SmtpClient("smtp.gmail.com");
sc.UseDefaultCredentials = false;
sc.EnableSsl = true;
sc.Credentials = new NetworkCredential("ajitagarwal2010@gmail.com", "pASSWORD");
sc.Send(mmsg);
Console.WriteLine("Email sent");
}catch (Exception ex)
{
Console.Write(ex.Message);
}
}
TRY IT
hi
DeleteI have a question. So if you use another email from your database without changing the codes, will it still work?
ReplyDeleteyou can use any email address if this email is present in database then application will send user name password values on that respective email address...
Delete{Label1.Text = "aryas@gmail.com"; //<--Enter your gmail id here
DeleteLabel2.Text = "94804";//<--Enter gmail password here
smtpc.Credentials = new NetworkCredential(Label1.Text, Label2.Text); }
Then what is this for?
Enter your gmail id and password here .It is used, any user can received his forget password value from this mail id(aryas@gmail.com)....
Deletewhen i am running this application , i am getting following error.pls help...
ReplyDelete"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
hello sir , I have one query in this form...in form design view first you drag & drop one lable,textbox,& button so in coding section way you can write in lable 1 & lable2 emailed & password ?
ReplyDeleteand I try it but it give error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required" ........... please slove my error in form that will I send you on gmail...
ReplyDeletehello sir , please answer me
ReplyDeletewhat is the solution for this error :System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
hi vrunda ! Use different gmail id then it will work.......
DeleteHi Vrunda,
DeleteBecause of security for gmail it wont allow recieve mails from unknown sender.
Solution is :
1)Go to Your gmail Account settings
2)Search for security tab
3)Find "Less Secure App Access" .Make sure it turned on and try your code
Note: Don't forget to make it turned off for secure your account
Thank u....
ReplyDeletehi !
ReplyDeletei need .dbo sql server. but you worked in .mdf so please send me how to work in .dbo sql server please
It's not working for me....
ReplyDeleteerror is:- Failure sending mail.
Hi,
ReplyDeleteFor these two lines
" + ds.Tables[0].Rows[0]["UserName"] + "
" + ds.Tables[0].Rows[0]["Password"] + "
its showing error.
Please suggest me what can i add to remove those errors
Hi Venkatesh, please specify the error name.Follow every steps carefully,you will never get this error.if any problem/error inform me....
Delete"Hi, Your UserName is : " + ds.Tables[0].Rows[0]["UserName"] + "Your Password is : " + ds.Tables[0].Rows[0]["Password"] + "";
ReplyDeletewrite it as a single-string...
I got this error.... Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
ReplyDeletefirst one is resolved now I got this error...Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
ReplyDeleteHow to send a forgot password code send me @ joysonabilash@gmail.com
ReplyDeleteHow can solve this error at line
ReplyDeletesmtpc.Send(email);
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
I'M getting the error as "Failure sending mail." what might be the reason?
ReplyDeleteAwesome Code...thnx ms.net
ReplyDelete" + ds.Tables[0].Rows[0]["UserName"] + "
ReplyDelete" + ds.Tables[0].Rows[0]["Password"] + "
sir error this lines