3

I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does.

How can I send an email from a Windows Batch (.bat) file?

Martin Brown
  • 24,692
  • 14
  • 77
  • 122

2 Answers2

4

Blat. Nothing more needs to be said. ;)

Mark Brackett
  • 84,552
  • 17
  • 108
  • 152
3

If the SMTP-server that is a part of IIS is installed, you could use the Echo command to write a file to the pickup folder, and it'll get sent.

echo From: test@example.com>tmp.txt
echo To: test@example.com>>tmp.txt
echo Subject: hello>>tmp.txt
echo.>>tmp.txt
echo Hello world>>tmp.txt
copy tmp.txt \Inetpub\mailroot\Pickup
Svante Svenson
  • 12,315
  • 4
  • 41
  • 45