Sending a SMTP email from a windows task

I was wondering if you can send a SMTP server email from a windows batch.

I have a server on port # 25.  It requires a username and password.

I have a batch that test whether a condition is "Y" or "N" and depending on the result one of two messages are sent.  Currently the messages are just echoing to the screen, but I want an email to be sent.

Here is my current batch code:

@echo on
setlocal EnableDelayedExpansion
for /F "skip=1 tokens=1-6 delims=," %%a in (D:\DTS\DailyATB\Daily_Bar_Midnight_Close.csv) do (

Echo %%a
Echo %%b
Echo %%c
Echo %%d
Echo %%e
Echo %%f

@Echo off
if "%%f" EQU "Y"  (
  Call :Yes
) else (
  Call :End

exit /b



echo ---------------------
echo BAR Closed
echo Crowe Files are ready to be transmitted for
echo %%c
echo ---------------------

Echo Yes
GoTo End


echo ---------------------
echo BAR did not close
echo ---------------------
Echo End

What do I need to do to program the email?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
1. Download BLAT command line mailer.
2. Replace the ECHO YES line with
blat - -to -f -server -u username -pw password -subject "Subject goes here" 

Open in new window

See for BLAT syntax
Bill PrewIT / Software Engineering ConsultantCommented:
Take a look at this answer to a prior question for more BLAT info, and an example of using a VBS approach.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GPSPOWAuthor Commented:
Thank you

Both solutions were very helpful

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Servers

From novice to tech pro — start learning today.