Easily Send Command Line Emails with Blat

Rate this post
Easily Send Command Line Emails with Blat

Blat. The name of a program that allows you to send emails to anybody in the globe from any application or software tool that you wish is not precisely the term you anticipate. It sounds more like the sound of a raw egg hitting the floor.

If you’ve never heard of it, that’s precisely what I’m going to present to you today. Blat is not new, but it is significant. There are various tools and services that will send email alerts for you automatically.

RSS news updates may be delivered to you automatically. Websites, such as the ten notification sites covered by Saikat, may send you email alerts. You may also use services like Google Analytics to deliver you automated information on a regular basis.

But what if you want to create batch processes or Windows scripts on your own computer that allow you to send emails directly from the command line? Blat is a Win32 tool that allows you to send emails using SMTP from the command line.

Setting Up Blat Command Line Emails

Blat is a free program that has been available since Windows 95 and has evolved throughout the years. It’s now accessible as a SourceForge project.

While Unix users have programs like sendmail to send command line emails, Windows users have relied on Blat to accomplish the same since Windows 95. Many computer users are unaware of how simple it is to send emails from the command line on Windows since they have never used blat. So, for those of you who haven’t seen it, let me introduce you to this incredibly simple but powerful command line program.

  7 Ways to Find All Accounts Linked to Your Email Address or Phone Number

You’ll find blat.dll, blat.lib, and blat.exe after downloading and extracting the Blat files. Place them all in the same folder, and then run the.exe file from there.

The first step is to use the “install” command to inform blat the SMTP server and account to use.

In this example, I used the command “blat -install smtp server> email user id>.”

This works for my SMTP account (no password necessary), but if yours needs authentication, add “-u username> -pw password>”, but bear in mind that blat still does not support SSL without a third-party program, thus it will not work with Gmail SMTP at this time. Once you’ve installed the id/pw and smtp server, you may run the blat command from the command line at any time.

In my case, I have a file named help.txt in the blat directory that has all of the blat command arguments. I want to use blat to send this text file as the email body. I can do this with a single command: “blat help.txt -to e-mail address to send to> -subject TestFile”

That’s it!

This command opens the test file, embeds it in the email body, uses the subject line you specified (no spaces), and then sends the email to the recipient you specified. This is how the email seemed to me when I got it.

While opening a command prompt and sending a fast email like this is wonderful, it’s much better to do it from inside a more sophisticated Windows Script.

Issue The Blat Command From Within A Windows Script File

In this scenario, my purpose is straightforward. I have a Windows script that pings a list of URLs that I keep in a text.ini file.

  How Does An Email Server Work? [Technology Explained]

Currently, if the script has a difficulty pinging any of the sites, it will display an alert box similar to this.

Instead of relying on a pop-up window, I’m going to enhance my script by sending an email if a website isn’t pingable. To do this, I’ll just add the following portion to my current Windows Script.

'If any ping failed, send an email

If Ping = false then

'* Send out email

wscript.echo "Sending " & strFailedList

"c:tempblatblat.exe -body " & strFailedList & " -to rdxxxxx@gmail.com -subject TestFile" Shell.run

End If

If you’ve never used scripting in WSF before, you must first execute the command “Set Shell = wscript.createObject(“wscript.shell”)” to configure it. Then, as seen above, use Shell.run to start the blat.exe command.

A few painful lessons concerning blat limits were learnt. The above command is only valid if the string variable’strFailedList’ has no spaces. To do this, I use a dash between each unsuccessful IP ping, as seen in my final email.

If you want a better-formatted email, you could always save any messages you wish to send to a file and then replace the “-body” argument with the file’s name instead (like the example I showed in the first half of this article).

As you can see, the blat program allows you to incorporate email sending into your Windows Scripts and opens up the prospect of receiving all kinds of helpful email warnings when anything goes wrong with your PC.

If you’ve never used the Blat tool before, give it a go and let us know what you think. Did you find any inventive applications for it in your Windows scripts? Share your thoughts and observations in the comments box below.

  If I change my Gmail password will my email account still be available on my iPad?

You are looking for information, articles, knowledge about the topic Easily Send Command Line Emails with Blat on internet, you do not find the information you need! Here are the best content compiled and compiled by the achindutemple.org team, along with other related topics such as: Email.

Similar Posts