Need help with sending email notification after successful /failed uploads in batch script

Advertisement

bumz
Joined:
Posts:
3

Need help with sending email notification after successful /failed uploads in batch script

Hi
I am new to writing batch files. I am looking to set up email notification if it failed or success for a upload. list below is my batch file.
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\FTPLogs\VCAL.log" /ini=nul ^
  /command ^
    "open sftp://******:******/ -hostkey=""*********""" ^
    "synchronize remote E:\VCAL /Diagnostics_******/VCAL" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit/b %WINSCP_RESULT%
The batch file works I just don't know how to setup the email. Please help! I have an IIS server that I can use as an smtp server to send emails. I just don't know how to add the code in the script above. When the upload exit code = 0 send success email. When exit code = 1 send fail email. I Have a batch file and my code inside is to call powershell run a ps1 script to send an email:
Powershell.exe -executionpolicy remotesigned -File  C:\bin\test\email.ps1
How do I make it work with the code above? thanks in advance.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum