检查电子邮件ID是否为windows live id

时间:2015-07-23 13:24:29

标签: asp.net-mvc-4 email email-validation windows-live-id

我正在开发MVC4应用程序,我想使用windows live id验证我的应用程序。我已经开发了可以邀请用户的页面,所以我想检查用户的电子邮件ID是否是windows live id?

我尝试过不同的东西,但他们只是验证电子邮件ID是否是gmail id。

我试过下面的代码。但它适用于Gmail,而不适用于windows live id

            TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25);
            string CRLF = "\r\n";
            byte[] dataBuffer;
            string ResponseString;
            NetworkStream netStream = tClient.GetStream();
            StreamReader reader = new StreamReader(netStream);
            ResponseString = reader.ReadLine();
            /* Perform HELO to SMTP Server and get Response */
            dataBuffer = BytesFromString("HELO KirtanHere" + CRLF);
            netStream.Write(dataBuffer, 0, dataBuffer.Length);
            ResponseString = reader.ReadLine();
            dataBuffer = BytesFromString("MAIL FROM:<YourGmailIDHere@gmail.com>" + CRLF);
            netStream.Write(dataBuffer, 0, dataBuffer.Length);
            ResponseString = reader.ReadLine();
            /* Read Response of the RCPT TO Message to know from google if it exist or not */
            dataBuffer = BytesFromString("RCPT TO:<" + email.Trim() + ">" + CRLF);
            netStream.Write(dataBuffer, 0, dataBuffer.Length);
            ResponseString = reader.ReadLine();
            if (GetResponseCode(ResponseString) == 550)
            {
                IsExist = false;
                //Response.Write("Mai Address Does not Exist !<br/><br/>");
                //Response.Write("<B><font color='red'>Original Error from Smtp Server :</font></b>" + ResponseString);
            }
            /* QUITE CONNECTION */
            dataBuffer = BytesFromString("QUITE" + CRLF);
            netStream.Write(dataBuffer, 0, dataBuffer.Length);
            tClient.Close();

还有其他方法可以达到这个目的吗?

1 个答案:

答案 0 :(得分:0)

这取决于您选择如何对用户进行身份验证。如果您使用Microsoft应用程序2.0进行身份验证,则真实帐户的“tid”声明为“”9188040d-6c67-4c5b-b112-36a304b66dad“,而工作或学校帐户具有独特的”tid“声明。

您还可以查看此问题以获取更多信息:How to determine if an email address is a Microsoft 'Work or School' account or a Microsoft Account