'**********************定义变量********************** Dim gmail_username ' GMAIL用户名 Dim gmail_password ' GMAIL密码 Dim mail_to ' 需要发送的邮箱 Dim mail_subject ' 需要发送的标题 Dim mail_content ' 需要发送的内容
'********************** script ********************** On Error Resume Next '错误继续执行 Set oIE=CreateObject("InternetExplorer.Application") '创建对象 oIE.Visible = True '设置可见 oIE.Navigate "http://www.gmail.com" '跳转URL While oIE.Busy: Wend '等待页面刷新完毕 With oIe.Document .GetElementById("Email").value=gmail_username .GetElementById("Passwd").value=gmail_password .GetElementsByName("signIn")(0).click End With '登录GMAIL While oIE.Busy: Wend '等待页面刷新完毕 WScript.Sleep 5000 '等待2秒 Set oWsh=CreateObject("wscript.shell") oWsh.SendKeys "{enter}" Set oWsh=Nothing '安全框确定 oIE.Navigate "https://mail.google.com/mail/?ui=html&zy=e" '跳转URL 标准HTML版本 While oIE.Busy: Wend '等待页面刷新完毕 For Each a In oIE.Document.GetElementsByTagName("A") If a.innertext="撰写邮件" Then a.click Exit For End If Next '点击撰写邮件 While oIE.Busy: Wend '等待页面刷新完毕 With oIE.Document .GetElementByID("to").value=mail_to .GetElementsByName("subject")(0).value=mail_subject .GetElementsByName("body")(0).innertext=mail_content .GetElementsByName("nvp_bu_send")(0).click End With '写MAIL WScript.Sleep 3000 While oIE.Busy: Wend '等待页面刷新完毕 For Each a In oIE.Document.GetElementsByTagName("A") If a.innertext="退出" Then a.click Exit For End If Next '点击退出 oIE.Quit '关闭浏览器 Set oIE=Nothing '释放资源 '********************** end **********************