VBScript to Automate login into gmail

Dim IE
Dim uSERNAME
Dim PASSWORD
Dim crtScreen
Set IE = CreateObject("InternetExplorer.Application")
USERNAME = "saudaziz"
PASSWORD = ""

With IE
.navigate "http://www.gmail.com"
.visible=1
End With

'wait a while until IE as finished to load
Do while IE.busy
loop
set WshShell = WScript.CreateObject("WScript.Shell")
Do While UCase(IE.Document.readyState) <> "COMPLETE"
WScript.Sleep 100
DoEvents
Loop
set WshShell=nothing
IE.document.all.Item("Email").value = USERNAME
IE.document.all.Item("pASSWD").value =pASSWORD
'IE.document.gaia_loginform.Email.value=USERNAME
IE.document.all.item("null").click
Set IE = Nothing

WScript.Quit(0)

3 comments:

SHYAM said...

Hi,this code seems to be good but there are no guidelines .for a layman like me its a bit difficult to identify where to insert the credentials.Hope you will update the code with some guidelines.
thanks
shyam

Saud Aziz said...

Line # 6 and 7 have USERNAME & PASSWORD variables, you should be assigning them your credentials.

Unknown said...

getting an error:
------------
Line: 26
Char: 1
Error: Object required: 'Documents.all.item(...)'
Code: 800A01A8
Source: Microsoft VBScript runtime error
-------------
though the fields are filled with the user and password but the page wont go further...
thanks in advanced.

Ramadan - What is it?

  Ramadan is one of the most important and holy months in the Islamic calendar. It is a time of fasting, prayer, and spiritual reflection fo...