batch-fileblat

Batch file: Blat sending 2 emails not 1


first time I've used blat and it appears to work fine however its sending two emails for every email I intend to send. Script excerpt is below:

::If we have a problem we email from here
CALL :checkForFailures

:checkForFailures
IF EXIST %ERROR_FILE% CALL :email & EXIT /B 1
::pause
GOTO :eof

:email
IF %TOLOG%==Y (
BLAT -f noreply@mydomain.com -to sapatos@mydomain.com -server myserver -subject "subject text" -body "Body text" -attacht 
::%PROBLEM_LIST% >> %LOGFILE%
) 

GOTO :eof

I've tried running this with and without output to the logfile. runs fine from the cmd prompt but just issues within this script.

Thanks for the help


Solution

  • Maybe you should stop your batch file after your call to :checkForFailures:

    ::If we have a problem we email from here 
    CALL :checkForFailures 
    goto :eof
    
    :checkForFailures
    ...
    

    Otherwise you call it once, and execution continues directly after the call. In which case it runs the :checkForFailures subroutine again and sends out a second mail.