Get the App
SLTechnology News&Howtos  ›  Servers  › 

Send email automatically through script under Windows

Shulou Source: shulou.com Published: 2022-06-03 01:58:48 10月02日 Update

Create a script file with an arbitrary name and the extension 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

Start the script, passing in parameters:

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

Tags: Scripts parameters names extensions files messages Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Docker Redmi MySQL