Use Blat to set Windows event emails from the command line
When you’re not around to monitor a PC then it’s often useful to get notifications of its key events. And so you might like to know when a particular program starts or ends, perhaps, or when the system closes down or restarts.
Some applications understand this already. Many backup programs are able to send email to let you know when a particular job has completed, for instance: very convenient. And Windows Task Scheduler can also send emails for a host of different events. But if that’s not enough then you can always manually extend your system with Blat, a simple command line tool which allows you to send emails as appropriate from your own scripts and batch files.
The process starts by setting up Blat with your core email details. Running the program at the command line will display its various settings and syntax, but in general a minimal setup will look something like this (with the bold text all on one line):
Blat -SaveSettings -f [email protected] -server mail.domain.com -u [email protected] -pw password
(Replace the first “[email protected]” with your sending address, “mail.domain.com” with your SMTP server, the second “[email protected]” with your account user name, and “password” with, well, your password.)
Next, create a plain text file with the text of whatever email you’d like to send. And it really does need to be plain text, as Blat transmits the contents of the file rather than sending it as an attachment. Call it test.txt for now and save it in the same folder as Blat.
With that done you can then probably send an email with a line like this:
Blat test.txt -to [email protected]
Where “[email protected]” is the email address of whoever you’d like to receive the message.
If that doesn’t work then simply enter Blat at the command line for the details of other switches you can apply (there’s the option to decide the port you’ll use to send the message, for instance).
And once your test emails are being sent correctly then you can begin building the program into your scripts, ready to send notifications of whatever events you like.
Photo Credit: Lilya/Shutterstock