Send Email via batch file
Posted on 2010-09-20
I am trying to create a batch file that will send an email to myself. I want to be alerted when services on Windows servers stop.
This will be used on Windows Server 2003 with Exchange 2003. The code I am using is below:
@echo off & setlocal
:: set the temp file location
:: echo the basic headers to the temp file
echo To: "Scripting Test" ^<firstname.lastname@example.org^> > %tempmail%
echo From: "Admin" ^<email@example.com^> >> %tempmail%
echo Subject: Test2 >> %tempmail%
:: echo the blank line that separates the header from the body text
:: echo the body text to the temp file
echo First line of body text.>> %tempmail%
echo Second line of body text.>> %tempmail%
:: move the temp file to the mail pickup directory
:: adjust this location for your system
move %tempmail% c:\inetpub\mailroot\pickup
The file gets created in the c:\inetpub\mailroot\pickup directory but then nothing happens. There is also a pickup directory under the exchange folders but that didn't work either.
Can anyone help?