views:

481

answers:

3

I want to make a program that tells you if you can login to an email account or not by entering their username and password into Windows Live.

It would connect to the Hotmail server and see if the user/pass combination is correct. If it can log in, it would display a label that the account is valid, if not it would say that the account is not valid.

How would I go about doing this?

Ok here's the totally incorrect code for logging in. I kind of borrowed it from sending an email:

Dim MyMailMessage As New MailMessage
MyMailMessage.From = New MailAddress(TextBox1.Text)
MyMailMessage.To.Add(TextBox1.Text)

Dim SMTP As New SmtpClient("smtp.live.com")
SMTP.Port = 25
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("textbox1.text", "textbox2.text")
SMTP.Send(MyMailMessage) // I have no idea how to get a response here... from the live server if it gives me a correct or incorrect response...

Can someone post an example code if they have a solution to this? Because I have no idea how to make this single handingly.

A: 

One option could be to use the WebBrowser control which would allow you to access the username and password input boxes, and would allow you to click the login button. You could then see which page the user is redirected to and that would tell you in the username/password combo is correct or not.

Jason Miesionczek
Ok, that seems like a good idea. But, ok, what if I had textbox1 which was the (username box) and textbox2 which is the (password box). When the press login how would the text values in these to boxes go to the correct places on the webbrowser?
Kevin
you would do something like this: browser.Document.GetElementById("username").SetAttribute("value", Info.Username); where browser is your WebBrowser control, and "username" is the ID of the input element on the page. And you would do the same thing for the password box. And then to click the login button, something like this would work:browser.Document.GetElementsById("login").InvokeMember("click"); It will get a little trickier if the login button doesn't have an ID, but its still possible to figure out how to find it using the other methods in the Document object.
Jason Miesionczek
for your example, you would replace Info.Username with textbox1.Text
Jason Miesionczek
Ok this is really getting confusing, can anyone give me an example on visual basic 2005 or 2008?
Kevin
A: 

Use Fiddler or HTTP Analyzer to see what happens when you sign in with a Browser. (I can give you a hand: A http post request is sent to https://login.live.com....)

All you have to do then is to mimic this request with the HttpWebRequest class in .NET. It's important that you make your request as similar as the one from the Browser as possible.

Jesper Palm
A: 

Mr.Jason Miesionczek

Thanks alot for the idea.. i am going to try that out.. bt are u sure that it works for all the logins in didderent webpages.

Thank u

Navin