Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

i need help in sending mail in C#.net.what 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

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
www.domainname.com/register/activate.aspx?id=OrpAirOxwkUnYoAPKWBQh9lA%2fdTTmcI8kgAAlaBW0Q5erWoFCwvDqvwzkB2g3UYa

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
cheers
 
Share this answer
 
v2
Comments
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".
[no name] 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 domainname.com
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
[no name] 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 telling..so if possible give me some codes for this..
Sandip.Nascar 22-Aug-12 7:05am    
check this link
http://www.4guysfromrolla.com/articles/062508-1.aspx
Try this one :-

C#
try
      {
          MailMessage mail = new MailMessage();
          mail.To = toMail;
          mail.From = "support@xyz.com";
          mail.Subject = "Welcome to xyz!!";
          mail.Body = table;
          mail.BodyFormat = MailFormat.Html;
          mail.Priority = MailPriority.High;
          SmtpMail.SmtpServer = "localhost";
          SmtpMail.Send(mail);
      }
      catch (Exception exe)
      {

      }
 
Share this answer
 
v3
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.
 
Share this answer
 
Comments
[no name] 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.
[no name] 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)



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