VBA自动登陆163信箱

来源:互联网 发布:落一叶而知秋 散文 编辑:程序博客网 时间:2024/03/28 23:28

 Sub Goto163()
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "http://mail.163.com"
Do Until .Readystate = 4
DoEvents
Loop
.Document.Forms(0).All(9).Value = "myusername"
.Document.Forms(0).All(13).Value = "mypassword"
.Document.Forms(0).All(35).Click
End With
MsgBox "Ok"
End Sub

或者:

Sub Goto163()
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "http://mail.163.com"
Do Until .Readystate = 4
DoEvents
Loop
.Document.Forms(0).All("username").Value = "myusername"
.Document.Forms(0).All("password").Value = "mypassword"
.Document.Forms(0).All("登录邮箱").Click
End With
MsgBox "Ok"
End Sub

附:

Sub show163tags()
Dim i As Byte
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "http://mail.163.com"
Do Until .Readystate = 4
DoEvents
Loop
On Error Resume Next
For i = 1 To 100
If Len(.Document.Forms(0).All(i).Name) > 0 Then Debug.Print "i=" & i; "  name=" & .Document.Forms(0).All(i).Name
Next
End With
MsgBox "ok"
End Sub

返回:

i=9  name=username
i=13  name=password
i=17  name=selType
i=24  name=remUser
i=26  name=secure
i=35  name=登录邮箱
i=40  name=登录网盘
i=62  name=style
i=63  name=product