Creating Tasks From Gmail Automatically

Creating Tasks From Gmail Automatically
This post was previously published. It has been updated.

Many people use their email as a task manager as well as an email program. I am convinced this is so because they don’t have an easy way to get the tasks from email into a task management system. Today we will look at how I automate Gmail into my task manager, Remember The Milk.

I am dead-set against using tools for purposes they are not designed for. That is one of the reasons I am strongly against using Gmail for task management. Gmail is an email program and its sole function should be to deal with email…sending, receiving, and storing.

The other reason is that when you use your email as a task manager, there are things that are going to be left out. You won’t put all your tasks in there, so you are either left with tasks in your head, or tasks in another system.

All your tasks should be in one place. And that place is not your email.

OK, rant over.

Tasks By Email

Most task managers will allow you email tasks to them. So if you are using a task manager that doesn’t have this feature, or if you are not using a task manager at all, find a task a manager that allows you to email tasks to it.

My personal choice is Remember The Milk. It has a lot of different features including the email feature.

Email Your Tasks

Next, learn how to make your email so that it meets the standards required by your task manager. To do this, look in the help for your task manager.

For Remember The Milk, you can email tasks in two ways: single tasks and multiple tasks. For emailing a single task, you put the task in the subject line of the email, and then add modifiers. Due dates are prefixed with ^. Tags are prefixed with #. Repeats are prefixed with *.

So if I wanted to enter an email task that is due tomorrow and repeats every Wednesday and the task name is “write article” the email subject would be “Write article ^tomorrow *every Wednesday”.

Creating a Task From An Email

One of the things about Remember The Milk is that if the subject line is used to create the task the body of the email is put into the note portion of the task.

So to create a task from the email, I would simply hit forward, then set up the email subject for the task. This puts the whole email into the task.

At this point I move the email out of my inbox with a label to indicate it has been sent to RTM.

Automating with Gmail

The previous steps can be done with any email package and any task package that accepts tasks by email. Now we are going to delve into automating Gmail specifically.

Setting Up Gmail Labels

In order to make this work, you need to have two labels: one to hold the tasks to be processed, and one to hold the tasks that have been processed into the task manager.

We do this to make sure that not asks gets processed twice. The procedure will take all tasks that are in “to process” folder, email them, and then move them into the “processed” folder.

The emails, in my set up are SendToRTM and SentToRTM, reflecting where they are in the process.

Setting Up The Script

The next part is to use a Google Script. Installing a script is fairly easy, and I will leave it to other articles (such as this one) to show you how to paste and run a Google Script.
Here is the script:

function SendToRTM() {
  //get all the emails labeled AutoRTM
  var label = GmailApp.getUserLabelByName('SendToRTM');
  var threads = label.getThreads();
  
  //for each email
  for (var i = 0; i < threads.length; i++)
  {
    var thread = threads[i];
    var messages = thread.getMessages();
    var lastMessage = messages[messages.length-1];
    var subject = "Action: " + lastMessage.getSubject().substring(0,54) + " #gmail";
    var rtmEmail = "myRTMemail@rmilk.com"; //put your task email address here
    
    try
    {
      //Send to RTM
      lastMessage.forward(rtmEmail, {subject: subject,});
    }
    catch(e)
    {
      GmailApp.sendEmail(rtmEmail, subject, "This email was unable to be forwarded. Check your Gmail Action Folder for the actual email");
    }
    
    //Apply labels SentToRtm
    var processedLabel = GmailApp.getUserLabelByName("SentToRTM");
    thread.addLabel(processedLabel);
    
    //Remove label SendToRTM
    thread.removeLabel(label);
    
    //mark as read
    thread.markRead();
  }
}

I then schedule the script to run automatically every 15 minutes, and all my email ends up in Remember the Milk.


This was a very high-level overview of how you can get email (specifically Gmail) to talk to a task program (specifically Remember the Milk). This same sort of thing can be done with any email package that allows programming (including Outlook) and any task application that will accept tasks by email.