自动生成密码并将其发送给新创建的用户电子邮件ID

编程入门 行业动态 更新时间:2024-10-26 19:38:35
本文介绍了自动生成密码并将其发送给新创建的用户电子邮件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

本文发布于:2023-05-31 22:07:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/400262.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自动生成   发送给   电子邮件   密码   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!