且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用户注册时如何在用户的电子邮件地址上发送唯一ID

更新时间:2023-09-24 21:07:16

首先创建一个唯一的使用您想要的任何ID,



您可能想要查看这个课程,



http://msdn.microsoft.com/en-us/library/system.random.aspx 一> [ ^ ]



或者正如迈克在评论中指出的那样,



- 一个SQL表的主键声明为自动递增的标识列将创建一个唯一的ID号





然后您向他们发送一封包含此唯一ID的电子邮件,



http://social.msdn.microsoft.com/Forums/en-US/ne tfxnetcom / thread / a75533eb-131b-4ff3-a3b2-b6df87c25cc8 [ ^ ]
First you create a unique ID using whatever you would like,

You might want to look into this class,

http://msdn.microsoft.com/en-us/library/system.random.aspx[^]

Or as Mike has pointed out in the comments,

- A SQL table''s Primary Key declared as an auto-incremented Identity column will create a unique id number


Then you send them an email with this unique id,

http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8[^]


只需使用当前日期,时间和秒数



如下所示,严重怀疑你有多少电子邮件发送重叠秒数



Just use the current date, time and seconds

something like below, seriously doubt you have that many emails to send to overlap the seconds

Dim uniqueID as string = DateTime.now.ToString("yymmddhms")





或长度为10





or for a length of 10

private string GenerateId()
        {
            long i = 1, j=-1;
            foreach (byte b in Guid.NewGuid().ToByteArray()){i *= ((int)b + 1);}
            foreach (byte b in Guid.NewGuid().ToByteArray()) { j *= ((int)b + 1); }
            var str1 = string.Format("{0:d}", (i - DateTime.Now.Millisecond));
            var str2 = string.Format("{0:d}", (j - DateTime.Now.Millisecond));
            return "EMC" + str1.Substring(0, 4) + str2.Substring(str2.Length/2, 3);
        }