本文介绍了自动生成密码并将其发送给新创建的用户电子邮件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何编写代码以自动生成密码并将其发送给新创建的用户电子邮件ID?
how to code for auto generate password and send it to newly create user email id?
推荐答案要生成随机密码,有两种方法: To generate a random pasword there are two approaches: string s = Guid.NewGuid().ToString();
string s = Membership.GeneratePassword();
后者仅适用于System.Web程序集. 要发送电子邮件,这里有一个通用的例程:使用C#发送带有或不带有附件的电子邮件:通用例程. [ ^ ] [edit]忘记了电子邮件要求-OriginalGriff [/edit]
The latter only works with the System.Web assembly. To email it, there is a generic routine to do that here: Sending an Email in C# with or without attachments: generic routine.[^] [edit]Forgot the email requirement - OriginalGriff[/edit]
使用随机类生成一些随机代码作为密码 这是生成随机字符的代码 Use Random Class to generate some random code as password This is code to generate random characters public string fillVerCode() { int codeCount = 6; string allChar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; string[] allCharArray = allChar.Split(','); string randomCode = ""; int temp = -1; Random rand = new Random(); for (int i = 0; i < codeCount; i++) { if (temp != -1) { rand = new Random(i * temp * ((int)DateTime.Now.Ticks)); } int t = rand.Next(36); if (temp != -1 && temp == t) { return fillVerCode(); } temp = t; randomCode += allCharArray[t]; } return randomCode; }
然后发送邮件 检查此链接 如何通过asp发送电子邮件 [ ^ ]
Then to Send Mail check this link How to send email through asp[^]
这是这个问题 [ ^ ].请只发布一次您的问题. This is a duplicate of this question[^]. Please post your questions once only.
更多推荐
自动生成密码并将其发送给新创建的用户电子邮件ID
发布评论