Using VB.NET to log into Windows Live Mail?

好久不见. 提交于 2019-12-11 16:38:58

问题


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.


回答1:


dim smtp as new smtpclient("smtp.live.com",25)
dim m as new mailmessage()'message must contains from, to, etc

with smtp

.usedefaultcredentials = false 'by default this is true
.credentials = new networkcredential("usuername","password")
.enablessl = true
.ishtmlbody = true
.send(m)
'or async
'.send(m,addresof enviado)' i'm not remember well if addressof is required here
end with


public sub Enviado
msgbox("mail message sended async")
end sub



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/1555936/using-vb-net-to-log-into-windows-live-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!