Click here to Skip to main content
13,189,324 members (65,425 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

i need help in sending mail in i need is as the user register, the user should get the userid and random generated password to his/her email id and using that they can login to the system.

Thank you
Posted 21-Aug-12 22:52pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The idea behind this is,

Keep a fields say status (bit datatype) in user table. Default it to 0.
When you send mail to user, encrypt the userid to 128 bit encryption.

like in user email, the link will lokk like this

You need to create the activate.aspx beforehand. In the code behind of the page, decrypt the id and check with your database.
Once success is returned, update the status field to 1.
and redirect to login page or confirmation page.

In addition, you can send the username and password in the mail body that you have already generated and stored in database.

Thats all
Sandip.Nascar 22-Aug-12 4:59am
one thing to add, while you login, check user credential along with status field.
If status is 0, show message, "Sorry, you are not activated".
snehasish nandy 22-Aug-12 5:04am
sandip the link u gave for activate.aspx is not opening..please check and give me the link again
Sandip.Nascar 22-Aug-12 5:56am
This is an e,g, there is no such domain name like
You need to create a page something like this, which will be opened only from email link. In the code behind check the id is available or not and update the status to one.

Remember, this is just for security (for activation) to stop spam
snehasish nandy 22-Aug-12 6:25am
that's what i need some code snippets or some idea how to code that.. theoretically i got what u r if possible give me some codes for this..
Sandip.Nascar 22-Aug-12 7:05am
check this link
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this one :-

          MailMessage mail = new MailMessage();
          mail.To = toMail;
          mail.From = "";
          mail.Subject = "Welcome to xyz!!";
          mail.Body = table;
          mail.BodyFormat = MailFormat.Html;
          mail.Priority = MailPriority.High;
          SmtpMail.SmtpServer = "localhost";
      catch (Exception exe)

Rate this: bad
Please Sign up or sign in to vote.

Solution 4

How I would do it

1. Have a user registration page.
2. Once user fills in everything generate a random password.
3. send this password to him in a email.
4. have a field in DB saying notVisited = true/1;
5. when the user logs in using this password.
6. when the user logs in check for notVisited.
7. if notVisited is true/1 push him to change password page.
8. set the notVisited = false/0;

Also, i would suggest that instead of sending him the default password send him an activation link instead. that approach is more robust and recommended.
snehasish nandy 22-Aug-12 5:16am
do u have any aritical, codes, links for sending this activation link ??
Rahul Rajat Singh 22-Aug-12 5:18am
Right now, NO. but i am also assigned a similar task. I will work on it pretty soon. so perhaps I will give you details once I am done with it.
snehasish nandy 22-Aug-12 5:47am
ok..sure..please do tell me as soon as u finish..

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171016.2 | Last Updated 22 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100