Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to generate and sent password to email address
Posted
Comments
Dylan Morley 28-May-12 5:59am    
Are you using the ASP.Net Membership provider?

Create a random password and email it.

Look here:
Generating Random Passwords with ASP.NET[^]
Sending Email in ASP.NET 2.0[^]
 
Share this answer
 
Create a TextBox to generate a password

On Submit Button Include the following code...


XML
Step 1: Declare the System.Net.Mail namespace
       using System.Net.Mail;

Step 2: Create a MailMessage object. This class contains the actual message you want to send. There are four overloaded constructors provided in this class. We will be using
      public MailMessage ( string from, string to, string subject, string body )
The constructor of this MailMessage class is used to specify the sender email, receiver email, subject, body.

MailMessage message = new MailMessage            ("abc@somedomain.com","UserMailId","Testing","TextBox1.Text.ToString(););

Step 3:After creating a message, use the SmtpClient to send the email to the specified SMTP server. I will be using ‘localhost’ as the SMTP server.

SmtpClient client = new SmtpClient("localhost");
client.Send(message);
 
Share this answer
 
generation of password has many ways like randomly by using random class, or from name +dob or some string+number (ss025) .
Sending mail is through system.net.mail u have to sent mails
see this link for sending email
Send Email in ASP.Net 2.0 - Feed back Form[^]


EX:
C#
string pswd=(txtname.text).substring(0,4)+(txtdob.text).substring(3,2);
SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();

        try
        {
            MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

            
            smtpClient.Host = "localhost";

           
            smtpClient.Port = 25;

            
            message.From = fromAddress;

            
            message.To.Add("123@gmail.com");
            message.Subject = "Password";

             
             

          
            message.IsBodyHtml = false;

            
            message.Body =  pswd;
         
            
            smtpClient.Send(message);

            Label1.Text = "Email successfully sent.";
        }
 
Share this answer
 
v2
Hi,
Use this link to generate a password and use above answers to send it to user:
http://www.4guysfromrolla.com/articles/101205-1.aspx[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900