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 SMTP.domainname.com 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

pause

:Yes


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

Echo Yes
GoTo End

:End

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



What do I need to do to program the email?

Thanks

Glen
GPSPOWAsked:
Who is Participating?
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.

NVITCommented:
1. Download BLAT command line mailer.
2. Replace the ECHO YES line with
blat - -to you@domain.com -f from@domain.com -server 10.1.1.1 -u username -pw password -subject "Subject goes here" 

Open in new window

See http://www.blat.net/syntax/syntax.html for BLAT syntax
http://www.blat.net/examples/batch.html
1
Bill PrewCommented:
Take a look at this answer to a prior question for more BLAT info, and an example of using a VBS approach.

http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_28382263.html#a39914699

~bp
0

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

Glen
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.