我有下面的代码,当控件进入它时,在命令提示符中打印(else代码)错误。但是我想要一个字符串,其中包含一个字符串中的所有错误(Concat之前的字符串),并使用该字符串发送邮件。 / p>
@echo off
echo Working !!!
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('type test.log ^| findstr "Queue_ID"') do (
set $Line=%%a
for /f "tokens=2 delims=^=," %%b in ('echo !$Line!') do (
set $Value=%%b
set $Value=#Queue_id!$Value: =!
if not defined !$Value! (set !$Value!=1) else (echo Error with [!$Value!])
))
endlocal
echo Done !!!
Pause
和邮件发送代码是
S:\blat.exe -body " error_String came from else code" -subject "KSD Error" -tf %recipients% -server %smtpserver% -f %sender%
答案 0 :(得分:0)
只有在出现错误时才会发送电子邮件:
@echo off
echo Working !!!
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('type test.log ^| findstr "Queue_ID"') do (
set $Line=%%a
for /f "tokens=2 delims=^=," %%b in ('echo !$Line!') do (
set $Value=%%b
set $Value=#Queue_id!$Value: =!
if not defined !$Value! (set !$Value!=1) else (set $liste=!$Liste!,[!$Value!])
))
if defined $Liste (
echo Error List : !$Liste!
echo sending Mail...
S:\blat.exe -body !$Liste! -subject "KSD Error" -tf %recipients% -server %smtpserver% -f %sender%)
endlocal
echo Done !!!
Pause