They are two different kind of batch files, one must be launched from FreeFileSync called batch file but is an xml file with all the configurations inside, its extension is .ffs_batch.
The other batch file, launched when .ffs_batch is done with the backup run, is the .bat I need to get to work. It's made ONLY for mailsend.exe, ONLY to try to read and send the logs via email when the backup run is done and when .ffs_batch calls it.
Apologize if this wasn't clear from the beginning, I assumed you all know FreeFileSync.
This is how it works:
FreeFileSync.exe (main program, can run even manually, itself) ---> Saved .ffs_batch (with all the configuration of the folders, when and where about saving log files, what to do on completion, even launch .bat files) ---> mailalert.bat (instructions for emailing logs) ---> mailsend.exe (only needed by mailalert.bat, smtp client).
edit:
I tried to let it scan every log but I have the same result, all logs are sent as [Success], even failed ones.
This is the code I used last
Code: Select all
@echo off
timeout 1
for /f "delims=" %%x in ('dir "C:\FFS\Logs\" /od /b') do set recent=%%x
findstr /m /C:"processed" "C:\FFS\Logs\%recent%"
if %errorlevel%==0 (
"C:\FFS\mailsend.exe" +bc +cc -v -smtp smtp.gmail.com -ssl -port 465 -auth -from 1STEMAIL -to 1STEMAIL -cc 2NDEMAIL -user 1STEMAIL -pass PASSWORD -sub "FFS_COMPANYNAME/PCNAME-BACKUPNAME: %time%, %date% - [Success] Synchronization completed successfully" -attach "C:\FFS\Logs\%recent%"
)
if errorlevel 1 (
"C:\FFS\mailsend.exe" +bc +cc -v -smtp smtp.gmail.com -ssl -port 465 -auth -from 1STEMAIL -to 1STEMAIL -cc 2NDEMAIL -user 1STEMAIL -pass PASSWORD -sub "FFS_COMPANYNAME/PCNAME-BACKUPNAME: %time%, %date% - [Failed] Synchronization completed with errors" -attach "C:\FFS\Logs\%recent%"
)
The word "processed" is on every log.
I give up until someone helps or/and wait for penpen to wake up.
penpen or whoever has 5 minutes, to make it easier, this is what I need:Return code 0? Attach last logfile.log with subject [Success]
Return code different than 0? Attach last logfile.log with subject [Failed]
That's it.
Thanks.