Gathering the data and generating reports may not be a big deal for you, but remembering to write up that email every so often can turn into a real hassle. And if you forget once or twice, it looks like you’re not on top of your game.
This is where your computer comes in handy.
Most Windows users know about the Windows Task Scheduler by now. In this article, I’m going to show you how you can use Windows Task Scheduler in combination with the awesome SendEmail SMTP command-line tool to send off scheduled, automated emails that include multiple attachments.
Configuring SendEmail to Correctly Send Reports
The task here is fairly simple. You have a directory where several automated reports are stored. Maybe it’s a logfile summary for servers that you support, which you need to forward to your supervisor. Maybe it’s an Analytics traffic report that you need to forward to your website clients. Regardless of the need, this technique will let you automatically fire off an automated report email that will include as many of those attachments that you need to send. So long as you have a system set up to automatically update those files before the scheduled email goes out – you’ll have a completely automated reporting system.
Here’s how it works. Let’s say I send out three Google Analytics reports that I generate and download every Thursday and I store them in a directory called C:/Analytics. When you download SendEmail from the link above, there’s no setup required. Just place it in any directory where you’d like to run it from. In this case I’m just placing it in the same directory, so that I don’t have to include the directory path to the attachments in my command line.
Linux users have been using the “sendmail” command for ages, so this isn’t really new to them, but the Windows compatible “SendEmail” tool is something that lets Windows users have the same sort of command-line functionality. Once you have the executable sitting in a directory like this, as long as you know the syntax, you can do a lot of cool stuff with the tool.
When you issue the “SendEmail” command at the command prompt (or run it from an application), you have to follow it with a number of parameters. The critical ones that we are concerned with are shown in the examples below.
- -f email@example.com : This parameter is the email address that will be the “sender.”
- -t firstname.lastname@example.org : This is the recipient’s email address.
- -u Monday Status Updates : This is the subject
- -m Here’s the analytics data for this week! : This is the message body.
- -a Analytics_Channel1.csv Analytics_Channel2.csv Analytics_Channel3.csv : These are the attachments.
- -s smtp.gmail.com:587 : SMTP server and port
- -xu email@example.com : SMTP authentication ID name
- -xp A1ienz2A51 : SMTP authentication password
- -o tls=yes : SMTP uses TLS (or SSL)
These are all of the parameters you’ll need to complete the task that I’m detailing in this article. Once you’ve downloaded the SendEmail.exe file to your computer, you’re ready to use Windows Task Scheduler to issue your SendEmail automated email command every day, week, or month.
Setting Up Windows Task Scheduler
Open up Windows Task scheduler by going to Start->Programs->Accessories->System Tools->Task Scheduler. Click to create a basic task.
This will walk you through the task scheduling wizard, where you can assign any calendar schedule you’d like for these emails to get sent.
On the next screen, select “Start a Program” and then you’ll see the screen where you need to set up the task. This is where you’ll enter the path for your SendEmail executable and the parameters.
The entire argument line that I typed in was as follows:
“-f firstname.lastname@example.org -u Monday Status Updates -m Here’s the analytics data for this week! -a Analytics_Channel1.csv -t email@example.com -s smtp.gmail.com:587 -xu firstname.lastname@example.org -xp xxxxxxx -o tls=yes“
Refer back to the parameter list above, but as you can see this sends out an email from your Gmail account to a recipient who has a Yahoo account with a subject line, “Here’s the analytics data for this week!” When this task runs (which will run every week), it fires off your message and attaches the file attachments that you’ve defined your parameters above.
This is what the received email looks like.
As you can see, there’s no indication that it comes from an automated script. Instead, it has a personal message and the necessary data/information files attached to the email. So long as you make sure the files are updated before this email goes out, you’ll never have to worry about forgetting to send out another one of these status updates again. You can look as though you’re being extremely productive. Meanwhile, you can work on Saikat’s approach to being a procrastination ninja!
Have you ever used the command-line SendEmail tool for Windows? Or maybe you have a different method for sending out automated emails? Share your own insight about this tool or other similar tools in the comments section below.
Image Credit: Tory Byrne