Karl's Cool Tools Podcast

Friday, December 30, 2005

Show #1: blat

I originally thought of this podcast as a way to motivate me to explore the Resource Kit and Support Tools that are available from Microsoft. But when I sat down to think about which tool to talk about first, I realized that I've used blat in many more places than any of the resource kit tools.

"Blat is a Win32 command line utility that sends email using SMTP or posts to usenet using NNTP." (straight from the official blat web site at www.blat.net)

I've used blat in many scripts to send me notifications or scheduled reports. You can also send SMS messages by emailing your phone number @ the correct domain (see a list here). Of course, SMTP is not known for reliable, immediate delivery, so I wouldn't use this method for your top-priority notifications.

How do you actually use blat? Here's the quick tutorial:

  1. Figure out what smtp server you're going to use. If you're using blat to send yourself alerts and reports from your servers, you should be able to use an internal smtp server at your company.

  2. Download the latest blat zip file from www.blat.net
  3. Unzip it and copy blat.exe to somewhere in your path (like c:\windows or c:\windows\system32)
  4. Check out the built-in docs by running blat for the short version or blat -h for all the details.

  5. Now you're ready to use it, but you might as well tell it to store some of the options in the registry with
    blat -install smtp.yourcompany.com youremail@yourcompany.com 3
    (that tells blat to use your smtp server by default, with your from address, and 3 retries).

  6. Now, sending an email is as easy as
    blat - -t someemail@somewhere.com -s "testing blat" -body "this is a test"
    (the "-" says not to read a file for the message body, the "-t" is short for "-to", and the "-s" is short for "-subject")

Here are some tips and other usage notes:

  • Put quotes around the subject and body text if they're more than one word.

  • One way to generate the body in a batch file is to echo lines to a temporary file and then
    blat c:\temp.txt -t email@yourcompany.com -s "scheduled report"

  • Other features that blat includes are attachment handling, debug mode for troubleshooting, and POP login if you need to authenticate to a POP server before sending.
That's about it for podcast #1. Send comments or suggestions for cool admin scripting and troubleshooting tools to karl.kranich at gmail.com.

2 Comments:

  • Hi,


    this site is a treasure chest of information. For me however, being a bit of a newbie to this I am still struggling to get this wonderful blat utility to work quite how I need it to and would appreciate any assistance you can give. What I am trying to achieve is to set blat to generate an email to me (from me) everytime a particular Windows service fails. I have created a text file with the message but I cannot get it to generate the email whereas it works fine when I generate the test command on your page. Any ideas? Use an example od DNS service failing please. Thanks in advance for any help[. My email, xhould you wish to send me any reply by mail is jchick@websense.com

    By Anonymous Anonymous, at 8:11 AM  

  • hi there,

    Your blat tutorial worked wonderfuly, tho im trying to add a .txt to the e-mail i keep getting error code 2, I'd aprecciate any support e-mail me if you have some time to spare ricardo.carvalho@ig.pt

    By Anonymous Anonymous, at 9:02 AM  

Post a Comment

<< Home