automatically send an email
Posted: 09 Apr 2019 00:54
I write an internet connection test program via file batch , and every time lose the network connection, it will automatically send an email to my gmail,The problem is the program will send an email continuously until it is connected again,It is very troublesome,so I want the program to send email once.
Code: Select all
set /p host1= "Please Input IP: "
set logfile=%host1%.log
echo DEST = %host1% > %logfile%
:Ping
ping %host1% -w 1000 -n 10 >> %logfile%
IF '%ERRORLEVEL%'=='1' GOTO SEND_MAIL
timeout 1 > NUL
GOTO Ping
:SEND_MAIL
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -file send_mail.ps1
GOTO Ping