Thursday, 22 August 2013

How to read the csv file and send the email to the users in it?

How to read the csv file and send the email to the users in it?

My code is
@echo on
setlocal ENABLEDELAYEDEXPANSION
setlocal
for /f "tokens=*" %%i in (output.csv)
do
(
for /f "tokens=1,2,3,4 delims=," %%a in ("%%i")
do
(
set date=%%a
set usr=%%b
set email=%%c
set nodays=%%d
set sub=Notification for password expiry
GOTO checkv
GOTO gotit
)
)
:checkv
IF [%nodays%] LEQ [10]
IF [%nodays%] GTR [0] (echo Your password for user %usr% is about to expire.)
IF [%nodays%] LEQ [0] (echo Tour password for user %usr% is expired.)
goto exit
:gotit
blat -body %body% -to %email% -server %smtpserver% -f %from_user%
-subject %sub% -sig %signature%
goto exit
But I get an error as below
C:\batch script>(
set date=17
set usr=priyanka
set email=pripawar@gmail.com
set nodays=9
set sub=Notification for password expiry
GOTO checkv
GOTO gotit
)
The syntax of the command is incorrect.
C:\batch script>IF [9] LEQ [10]
C:\batch script>
It seems it fails at the If condition. Can anyone help to get it work...

No comments:

Post a Comment