Pinterest Stumbleupon Whatsapp
Ads by Google

<firstimage=”http://www.makeuseof.com/wp-content/uploads/2010/07/late.jpg”>automated emailsNo matter what your job is, usually everyone at some point has to email a boss or supervisor with daily, weekly or monthly status reports. A lot of time this is nothing more than sending over a spreadsheet of data, logfiles or other reports that are usually automatically generated.

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 Run Programs Automatically Using Windows Task Scheduler Run Programs Automatically Using Windows Task Scheduler Read More 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.

Ads by Google

automated emails

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 xxxxx@gmail.com : This parameter is the email address that will be the “sender.”
  • -t rdube@yahoo.com : 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 xxxxx@gmail.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.

how to automate emails

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.

how to automate emails

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.

how to automate emails

The entire argument line that I typed in was as follows:

-f xxxxx@gmail.com -u Monday Status Updates -m Here’s the analytics data for this week! -a Analytics_Channel1.csv -t xxxxx@yahoo.com -s smtp.gmail.com:587 -xu xxxxx@gmail.com -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.

automated emails

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 8 Tools That Will Make You a Procrastination Ninja at Work 8 Tools That Will Make You a Procrastination Ninja at Work Read More !

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

  1. Daniel
    July 31, 2016 at 6:02 pm

    Hi there!

    Very useful tool! One simple question. I would like to run the .exe file from another application other than Task Scheduler... and it will always be the exact same email that will be sent, for example, every time the app loses connection to a server, then it will execute the file and an email will be sent notifying me that the app lost connection. So how would I set the parameters in this scenario since I won't be using Task Scheduler?

    Thank you do much,

    Daniel -

  2. Rohit
    March 15, 2016 at 9:52 am

    How to put email in CC. Please help me with this.

  3. David O'Brien
    October 6, 2015 at 5:41 am

    Thanks Ryan. I have just been talking about how easy it should be to do this but couldnt find a way. This was easy but.....message I get is "The task definition uses a deprecated feature"

    I just want to send an email every Monday asking staff to remember to do a stationary order. Better yet reply to the email with their order
    Thanks

    • David O'Brien
      October 8, 2015 at 3:58 am

      We kind of used a workaround using HTML code and it is ok. Not great but ok

  4. Integrated marketing communications
    December 29, 2014 at 6:06 pm

    Can someone post an example line for a verizon.net email address? I’m having a hard time with this…

    • Chuck
      February 19, 2016 at 5:07 pm

      I've never got it to work with verizon either. I know you need to use the latest version and include the -o tls=yes switch but no matter what I try I get "ERROR => smtp.verizon.net:465 returned a zero byte response to our query."

      • man
        June 1, 2016 at 1:16 pm

        I am also getting same error for gmail.
        ERROR=>smtp.gmail.com:465 returned a zero byte response to our query

  5. Ryan Dube
    September 23, 2010 at 8:53 am

    Hey Jeff, that looks correct to me. What version of Windows are you using and are you confident you have a good outside Internet connection that you can use normally to send mail out using the smtp server you identified?

  6. Jeff
    September 22, 2010 at 3:10 pm

    I'm getting this strange error when I try to use sendmail in command prompt:

    Sep 22 15:05:06 <computername> sendemail[4872]: ERROR => Connection attempt to smtp.gmail.com:587 failed: IO::Socket::INET: connect: Unknown error

    This is what i type:
    C:\Users\<username>>sendemail -f <username>@gmail.com -u Subject test -m test
    -t <username>@gmail.com -s smtp.gmail.com:587 -xu <username>
    @gmail.com -xp <password> -o tls=yes

    Is this correct?</password></username></username></username></username></computername>

  7. Jeff
    September 22, 2010 at 1:10 pm

    I'm getting this strange error when I try to use sendmail in command prompt:

    Sep 22 15:05:06 sendemail[4872]: ERROR => Connection attempt to smtp.gmail.com:587 failed: IO::Socket::INET: connect: Unknown error

    This is what i type:
    C:Users>sendemail -f @gmail.com -u Subject test -m test
    -t @gmail.com -s smtp.gmail.com:587 -xu
    @gmail.com -xp -o tls=yes

    Is this correct?

  8. EE
    August 31, 2010 at 2:40 am

    Can someone post an example line for a verizon.net email address? I'm having a hard time with this...

  9. EE
    August 31, 2010 at 12:40 am

    Can someone post an example line for a verizon.net email address? I'm having a hard time with this...

  10. Ryan Dube
    July 30, 2010 at 1:22 am

    Hey Chris, thanks!

    Based on some of the comments in the FAQ, there is a known limit for the message of 16kb. You've stumped me on the subject line though - I don't know!

  11. Chris_Hunter
    July 29, 2010 at 10:18 am

    Ryan,

    This is a GREAT tutorial on using these tools! Really great stuff!

    Let me ask you a question or two: for the -m Message Body, is there a max limit of characters or words that can go there? What about the Subject Line? Max there as well?

    Thanks!

  12. Chris_Hunter
    July 29, 2010 at 8:18 am

    Ryan,

    This is a GREAT tutorial on using these tools! Really great stuff!

    Let me ask you a question or two: for the -m Message Body, is there a max limit of characters or words that can go there? What about the Subject Line? Max there as well?

    Thanks!

    • Ryan Dube
      July 29, 2010 at 11:22 pm

      Hey Chris, thanks!

      Based on some of the comments in the FAQ, there is a known limit for the message of 16kb. You've stumped me on the subject line though - I don't know!

      • Chris_Hunter
        July 31, 2010 at 4:20 am

        16kb is a good amount of plain text data. More than enough for a blog post! Thanks, Ryan!

    • Aibek
      July 30, 2010 at 10:37 am

      I second Chris, great tutorial!

Leave a Reply

Your email address will not be published. Required fields are marked *