|I’m using blat http://www.blat.net/ as a command line emailer and it’s working fine|
Now I would like to add to my batch script some improvement: i.e. errorlevel checking in order to control the user input data to be sure that a valid email address is set to the %from% variable;
This is my very rough attempt not working on the error level part (errorlevel 12 is when -server or -f options is not specified or not found in registry)
:: setting vars
set cc= email@example.com
set bcc= firstname.lastname@example.org
set /p from="your email..."
set subject="subject text here"
set server=-server xxx.xxx.xxx.xx
set debug=-debug -log blat.log -timestamp
:: running blat
blat -attach file.txt -f %from% -to %to% -cc %cc% -bcc %bcc% -s %subject% %server% %debug% -body "body text here"
:: control error
IF ERRORLEVEL=12 THEN GOTO :ERROR12
::if no error code...
ECHO ERROR: specify email address
::end of batch here
Any help for that?
To improve further the batch my ideal solution would be to loop through until a valid email address is specified: the email address is composed by a variable part (the name of the sender) and by a fixed part (the name of the domain, which is in my case always the same)