This one works perfectly:
@echo off
set subject=[Failed] The search terms were not found
for /f "delims=" %%x in ('dir "C:\FFS\Logs\" /od /b') do set recent=%%x
findstr /i /c:"successfully" /c:"Nothing to synchronize" "C:\FFS\Logs\%recent%" >nul && set subject=[Success] Synchronization completed successfully
findstr /i "warnings errors aborted" "C:\FFS\Logs\%recent%" >nul && set subject=[Failed] Synchronization completed with errors
"C:\FFS\mailsend.exe" +bc +cc -v -smtp smtp.gmail.com -ssl -port 465 -auth -from EMAIL -to EMAIL -cc EMAIL -bc EMAIL -user EMAIL -pass PASSWORD -sub "FFS_COMPANYNAME/SOURCE-FOLDER_DESTINATION-FOLDER_WHEN: %time%, %date% - %subject%" -attach "C:\FFS\Logs\%recent%"
Send logs for every error help
- Posts: 16
- Joined: 13 Apr 2014
- Site Admin
- Posts: 7211
- Joined: 9 Dec 2007
I think the problem with your previous versions was that you did not write the error cases in reverse like:
if errorlevel 3 (
::error code is 3 or greater
)
if errorlevel 2 (
::error code is 2 or greater
)
if errorlevel 1 (
::error code is 1 or greater
)
if errorlevel 3 (
::error code is 3 or greater
)
if errorlevel 2 (
::error code is 2 or greater
)
if errorlevel 1 (
::error code is 1 or greater
)
- Posts: 16
- Joined: 13 Apr 2014
Zenju, thank you for your reply. I thought once you define "if errorlevel 1" every other higher level was going to be included in this section and excluded from a new different errorlevel search.
This final script I am using works perfectly, if I find any issue I will try to tweak it with the one suggested by you.
This final script I am using works perfectly, if I find any issue I will try to tweak it with the one suggested by you.