千家信息网

Windows下通过脚本自动发邮件

发表于:2024-11-17 作者:千家信息网编辑
千家信息网最后更新 2024年11月17日,创建一个脚本文件,名字随意,扩展名vbssubject=WScript.Arguments(0)content=WScript.Arguments(1)set sh=WScript.CreateObj
千家信息网最后更新 2024年11月17日Windows下通过脚本自动发邮件

创建一个脚本文件,名字随意,扩展名vbs

subject=WScript.Arguments(0)content=WScript.Arguments(1)set sh=WScript.CreateObject("WScript.Shell")host=WScript.FullNameIf LCase(Right(host,11))="wscript.exe" Then    sh.run "cscript //nologo """ & WScript.ScriptFullName & Chr(34), 0    WSCript.QuitEnd Ifsh.Run "cmd.exe"WScript.Sleep 1000sh.SendKeys "telnet"sh.SendKeys("{Enter}")WScript.Sleep 1000sh.SendKeys "open smtp.somesome.com 25" sh.SendKeys("{Enter}")WScript.Sleep 1000sh.SendKeys "helo somesome.com" sh.SendKeys("{Enter}")WScript.Sleep 500sh.SendKeys "auth login" sh.SendKeys("{Enter}")WScript.Sleep 500sh.SendKeys "xxxxxxx" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "xxxxxxx" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "mail from:" sh.SendKeys("{Enter}")WScript.Sleep 500sh.SendKeys "rcpt to:" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "rcpt to:" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "data" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "from:test1" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "to:test2" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "subject:" & subject sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys content sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys "." sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys("{Enter}")WScript.Sleep 1000sh.SendKeys "quit" sh.SendKeys("{Enter}")WScript.Sleep 5000sh.SendKeys("{Enter}")WScript.Sleep 2000sh.SendKeys "quit" sh.SendKeys("{Enter}")WScript.Sleep 100sh.SendKeys("exit{Enter}")WScript.Quit

启动脚本,传入参数:

cscript //Nologo SendMail3.vbs subject-%time% content111


0