Hi,
Have a look at this page:-
http://webmail.vsnl.com/
I want to login to my VSNL account through VB using Web Browser Control. Is it possible?
How to fill the textboxes and click on login button using VB?
Printable View
Hi,
Have a look at this page:-
http://webmail.vsnl.com/
I want to login to my VSNL account through VB using Web Browser Control. Is it possible?
How to fill the textboxes and click on login button using VB?
Sure - what's your username and password?
Just kidding, actually I do this to get information from my contractor's websites all time.
Try this - note where I put comments for user name and password and server. If you study HTML Dom you could navigate the entire site. Remove the quit statement and the browser wont close.Code:Sub getMail()
Dim ie As Object, wsh As Long, x As Object
Set ie = CreateObject("Internetexplorer.Application")
ie.navigate ("http://webmail.vsnl.com/")
While ie.busy: DoEvents: Wend
ie.Visible = True
While ie.busy: DoEvents: Wend
'your user id
ie.document.Forms(0).Elements("userid").Value = "user"
'your password
ie.document.Forms(0).Elements("password").Value = "password"
'your server
For Each x In ie.document.Forms(0).Elements("server").Options
If x.Value = "vsnl.com" Then x.Selected = True
Next
ie.document.Forms(0).submit
While ie.busy: DoEvents: Wend
msgbox "you're in!!!-click OK to close browser"
While ie.busy: DoEvents: Wend
ie.Quit
Set ie = Nothing
End Sub
http://www.w3schools.com/htmldom/default.asp
Thanks for the code. Its showing invalid username or password. It was happening so fast. So I used camstudio to record and i found the user, sever and password was correct.
I have tried the code for yahoo. It worked.
PHP Code:Dim i As Integer
Sub getMail()
Dim ie As Object, wsh As Long, x As Object
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://mail.yahoo.com")
While ie.Busy: DoEvents: Wend
ie.Visible = True
While ie.Busy: DoEvents: Wend
'your user id
ie.Document.Forms(0).Elements("login").Value = "username"
'your password
ie.Document.Forms(0).Elements("passwd").Value = "mypass"
While ie.Busy: DoEvents: Wend
ie.Document.Forms(0).submit
While ie.Busy: DoEvents: Wend
MsgBox "you're in!!!-click OK to close browser"
While ie.Busy: DoEvents: Wend
ie.Quit
Set ie = Nothing
End Sub
Private Sub Command1_Click()
Call getMail
End Sub
Sometimes it gives error "Object variable not set or with block variable" in my yahoo mail code
On what line do you encounter the error?
The following line:-
Code:ie.Document.Forms(0).Elements("login").Value = user
What does the error mean?
Though I have wrote "On Error Resume Next" line at the beginning of function. Now its fixed.
Could you try it like this? It will just check if it's state is ready.
Code:Sub getMail()
Dim ie As Object
Dim wsh As Long
Dim x As Object
Const READYSTATE_COMPLETE = 4
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://mail.yahoo.com")
While ie.Busy
DoEvents
Wend
While ie.ReadyState <> READYSTATE_COMPLETE
DoEvents
Wend
ie.Visible = True
While ie.Busy
DoEvents
Wend
'your user id
ie.Document.Forms(0).Elements("login").Value = "username"
'your password
ie.Document.Forms(0).Elements("passwd").Value = "password"
While ie.Busy: DoEvents: Wend
ie.Document.Forms(0).submit
While ie.Busy: DoEvents: Wend
MsgBox "you're in!!!-click OK to close browser"
While ie.Busy: DoEvents: Wend
ie.Quit
Set ie = Nothing
End Sub
Though your code is not giving error as before but it shows worng ID and password when i use it for webmail.vsnl.com
Upto filling the textbox its OK but when the submit code is executed then the webpage shows error but when i manually click the submit button then it logs in to my account.
I have also applied the timer but it was of no use.
Code:Dim ie As Object
Public Function getMail()
Dim wsh As Long
Dim x As Object
Const READYSTATE_COMPLETE = 4
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://webmail.vsnl.com")
While ie.Busy
DoEvents
Wend
While ie.ReadyState <> READYSTATE_COMPLETE
DoEvents
Wend
ie.Visible = True
While ie.Busy
DoEvents
Wend
'your user id
ie.document.Forms(0).Elements("userid").Value = "MYID"
'your password
ie.document.Forms(0).Elements("password").Value = "MYPASS"
ie.document.Forms(0).Elements("server").Options.Value = "vsnl.net"
While ie.Busy: DoEvents: Wend
Timer1.Enabled = True
End Function
Private Sub Command1_Click()
Call getMail
End Sub
Private Sub Timer1_Timer()
ie.document.Forms(0).submit
Timer1.Enabled = False
End Sub
Here are the screen-shots of the page after executing the program:-
By the way, HAPPY NEW YEAR!
What error is raised when you submit the form?
Error is not raised. But when the submit is done through Program then it doesn't work. The webpage shows " Wrong User ID or Password ".(Though UserID and password is correct) When I manually click submit button then it works.
How are you submitting programatically?
ie.document.Forms(0).submit
You can't set option value it must be and index!
incorrect:
correct:Code:ie.document.Forms(0).Elements("server").Options.Value = "vsnl.net"
Code:For Each x In ie.document.Forms(0).Elements("server").Options
If x.Value = "vsnl.net" Then x.Selected = True
Next
@techno
No, Its selected. See the screen-shots posted above. I also tried your code, its selecting but again the webpage is throwing error.
Could you post all the relevant codes?
How can i do it for vbforums.com ??? i tried the following code and it didn't work.
Code:Dim i As Integer
Sub getMail()
Dim ie As Object, wsh As Long, x As Object
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://vbforums.com")
While ie.Busy: DoEvents: Wend
ie.Visible = True
While ie.Busy: DoEvents: Wend
'your user id
ie.Document.Forms(0).Elements("login").Value = "wiz...."
'your password
ie.Document.Forms(0).Elements("passwd").Value = "password"
While ie.Busy: DoEvents: Wend
ie.Document.Forms(0).submit
While ie.Busy: DoEvents: Wend
MsgBox "you're in!!!-click OK to close browser"
While ie.Busy: DoEvents: Wend
ie.Quit
Set ie = Nothing
End Sub
Private Sub Command1_Click()
Call getMail
End Sub
btw who logged into ma account??????????plz PM me....
Code:Dim ie As Object
Public Function getMail()
Dim wsh As Long
Dim x As Object
Const READYSTATE_COMPLETE = 4
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://webmail.vsnl.com")
While ie.Busy
DoEvents
Wend
While ie.ReadyState <> READYSTATE_COMPLETE
DoEvents
Wend
ie.Visible = True
While ie.Busy
DoEvents
Wend
'your user id
ie.document.Forms(0).Elements("userid").Value = "avinternational"
'your password
ie.document.Forms(0).Elements("password").Value = "password"
For Each x In ie.document.Forms(0).Elements("server").Options
If x.Value = "vsnl.net" Then x.Selected = True
Next
While ie.Busy: DoEvents: Wend
Timer1.Enabled = True
End Function
Private Sub Command1_Click()
Call getMail
End Sub
Private Sub Timer1_Timer()
ie.document.Forms(0).submit
Timer1.Enabled = False
End Sub
Pl help dee-u
I am not sure what's wrong since I cannot test it fully without a valid username and password, of course I always get an 'invalid' error. Could it be that the form has a different index?
@Wiz
Each Webpage is different - so you have to examine the source.
In the case of VBforums the search form is first and the login is second. Also the Names of the controls are specific to the form, the correct code is below,
Make sure you logoff before trying to log in.
Code:Private Sub Command1_Click()
Dim i As Integer
Dim ie As Object, wsh As Long, x As Object
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://vbforums.com")
While ie.Busy: DoEvents: Wend
ie.Visible = True
While ie.Busy: DoEvents: Wend
'your user id
ie.Document.Forms(1).Elements("vb_login_username").Value = "youlogin"
'your password
ie.Document.Forms(1).Elements("vb_login_password").Value = "yourpassword"
While ie.Busy: DoEvents: Wend
ie.Document.Forms(1).submit
While ie.Busy: DoEvents: Wend
MsgBox "you're in!!!-click OK to close browser"
While ie.Busy: DoEvents: Wend
ie.Quit
Set ie = Nothing
End Sub
@techno
You r right. In my case the code is absolutely correct. The webpage is filling up with correct values. Now i will give my user and pass to dee-u through private message.
Hey! Dee-U i have sent you the User and Pass for webmail.vsnl.com.
Cheers pal, here's how you will submit it. You can now change your password!
Code:ie.document.All("Submit").Click
Thanks. Actually now i am using MS-OUTLOOK but i just asked because i was curious to know.
Thanks very much.
How you identified it. Is it because of this code ?
<input name="Submit" type="submit" class="blue11b" value="Sign In" onclick="post();">
I am making an application which Checks mail and also only shows No. of Yahoo Mails Total and Unread in a label.
I have successfully done that by using INET control and string handling function.
The only problem is that i want that the ie window should not be visible. Though i have set the boolean value to false but then also a window opens with this URL. Its only in case of yahoo webpage:-
http://search.yahoo.com/web?fr=ush1-mail
Code:-
Code:Sub getMail(v As Boolean)
On Error Resume Next
Dim ie As Object, wsh As Long, x As Object
Set ie = CreateObject("Internetexplorer.Application")
ie.Navigate ("http://mail.yahoo.com")
While ie.Busy
DoEvents
Wend
While ie.ReadyState <> READYSTATE_COMPLETE
DoEvents
Wend
ie.Visible = False
While ie.Busy
DoEvents
Wend
'your user id
ie.Document.Forms(0).Elements("login").Value = Text1.Text
'your password
ie.Document.Forms(0).Elements("passwd").Value = Text2.Text
While ie.Busy
DoEvents
Wend
ie.Document.Forms(0).submit
While ie.Busy: DoEvents: Wend
loc = ie.LocationURL
End Sub
Yes, that was my clue and tried it and it worked like a charm. If you are using INET then why are you still using IE? I could not understand what you meant, perhaps it needs another thread for such diversce concern.
If you are using INET then why are you still using IE?
Actually i am using it to accomplish two different task. I know it can be done only by using INET but still i want to know the reason of the webpage that is opening. When the value is set to true then two window appears.
I want to know Why ?
Not sure about the window that appears but instead of IE you can use your own WebBrowser which acts the same as IE.
Hi guys, I was looking at this thread and am able to reproduce the great advice given.
What I am interested in is that the opening of a form, entering information into the boxes and "clicking" on the submit seems old. I am a beginner so please forgive me when I am misunderstanding something here, but couldn't we just shorten the logon to a single URL or to what ever clicking on the Submit button does?
Isnt the "click" going to submit a url something like this?
thus why cannot we just navigate directly to this in the first instance?Code:www.whatever......php?vb_login_username=youlogin&vb_login_password=yourpassword
That would work in a "GET" Method form but not in a "POST" Method form.
Here's the W3 link
http://www.w3.org/MarkUp/html-spec/h..._8.html#SEC8.2
Thanks for replying.
I am actually doing some googling on it right now. seems I have this
http://www.developerfusion.com/artic...-a-web-page/2/
I am actually looking at POST