Create Google Tasks by sending email to Google GMail Address

I use Google Tasks for a quick to-do list. It has clean interface and is easy to use. On desktop or laptop machine, it is built-in to Google Mail for a quick access. On smartphones, many to-do apps including Tasks N Todos sync with Google tasks.

The neat thing is that in the Google Mail, you can add Gmail messages into the task list very easily by selecting the messages and then using More Actions > Add to Tasks.

What if you want to add email messages from other mails like that from work, or Yahoo Mail, etc., it doesn’t seem that there is a straightforward way to do so.

I found this web log on the automated email-to-task with Google Apps Script by DJ Adams. The Google Apps Script is able to parse the email with a specific filtered label and create a task automatically. Let’s give it a try.

The overall process is as follows:

  • Two new Gmail labels need to be created – newtask and newtaskdone. When a new email is arrived, the filter will label it with newtask. Once the script processes this email, it will be re-labeled to newtaskdone so it won’t be processed again.
  • To make sure that only specified emails – not all – are processed, one of the hidden features of Gmail will be used. The filter will look for only +task@gmail.com (such as ittichai+task@gmail.com) in the TO address to apply new label. Read this on how to use “+” (plus ) or “.” (dot) in your Gmail address.
  • The Apps Script is from the Google Spreadsheet. The original post is to use only the email’s subject for the task’s title but I modified codes a bit to include the email’s body to be the task’s body as well.
  • One of the important things is to integrate the script with Google API so it will allow to use the Google Tasks’ API service and content.
  • Schedule it to run with a needed interval. I’m doing it every 30 minutes. Note that there is a courtesy limit of 5,000 requests per day. But this should be more than enough for a normal use.

Courtesy Limit of Tasks API

  • Now just simply forward all emails to+task@gmail.com if you want to add them into the task list. It should show up in the Google Tasks within your specified interval.

All step-by-step instructions can be found at my wiki site.

23 thoughts on “Create Google Tasks by sending email to Google GMail Address”

  1. This was *exactly* what I was looking for! Not being able to add tasks via the native gmail app was the only reason I wasn’t using it. Thank you very much for posting this info and for being detailed with the instructions. /cheer

  2. I am excited about this script and looking forward to implementing it. I feel I am very close, except for the following error:

    Execution failed: ReferenceError: “Tasks” is not
    defined. (line 75, file “Code”) [0.474 seconds
    total runtime]

    Here is a copy of my log:

    [14-01-16 14:52:23:318 EST] Starting execution
    [14-01-16 14:52:23:330 EST] SpreadsheetApp.getActiveSpreadsheet() [0 seconds]
    [14-01-16 14:52:23:438 EST] Spreadsheet.getSheets() [0.107 seconds]
    [14-01-16 14:52:23:447 EST] Sheet.toString() [0 seconds]
    [14-01-16 14:52:23:447 EST] Spreadsheet.setActiveSheet([Sheet]) [0.008 seconds]
    [14-01-16 14:52:23:657 EST] GmailApp.getUserLabelByName([newtask]) [0.208 seconds]
    [14-01-16 14:52:23:659 EST] GmailApp.getUserLabelByName([newtaskdone]) [0 seconds]
    [14-01-16 14:52:23:719 EST] GmailLabel.getThreads() [0.059 seconds]
    [14-01-16 14:52:23:719 EST] GmailThread.getFirstMessageSubject() [0 seconds]
    [14-01-16 14:52:23:753 EST] GmailThread.getMessages() [0.033 seconds]
    [14-01-16 14:52:23:755 EST] GmailMessage.getBody() [0 seconds]
    [14-01-16 14:52:23:797 EST] Xml.parse([body of new task email
    , true]) [0.042 seconds]
    [14-01-16 14:52:23:798 EST] XmlDocument.getElement() [0 seconds]
    [14-01-16 14:52:23:798 EST] XmlElement.toString() [0 seconds]
    [14-01-16 14:52:23:798 EST] XmlElement.toString() [0 seconds]
    [14-01-16 14:52:23:799 EST] XmlText.toString() [0 seconds]
    [14-01-16 14:52:23:799 EST] XmlText.toXmlString() [0 seconds]
    [14-01-16 14:52:23:800 EST] XmlElement.toString() [0 seconds]
    [14-01-16 14:52:23:800 EST] XmlAttribute.toString() [0 seconds]
    [14-01-16 14:52:23:800 EST] XmlText.toString() [0 seconds]
    [14-01-16 14:52:23:800 EST] XmlText.toXmlString() [0 seconds]
    [14-01-16 14:52:23:805 EST] Execution failed: ReferenceError: “Tasks” is not defined. (line 75, file “Code”) [0.474 seconds total runtime]

    Perhaps I made a mistake?

    I did setup the labels in gmail, and I copied-and-pasted the script fully, except I did change the value of the TASKLIST variable (as required) as shown below.

    TASKLIST = “list5”;
    LABEL_PENDING = “newtask”;
    LABEL_DONE = “newtaskdone”;

    My task list is called “list5”

    Any suggestions?

      1. Ahh. Yes, I missed that part. After following those instructions, the script now does work. Wonderful job! You rock, dude!

  3. Hi, great post! Is there a script to send an email of the new task every time it is added in Google Tasks?

    And even better, an script that can batch email each old task from Google Tasks as individual emails?

    I’ve got 600+ tasks that I need to email for labelling/sorting in Gmail! Thanks, Adam

    1. Adam,

      You can use this script to send an email out for every new task it processes.

      MailApp.sendEmail('ittichai@gmail.com', taskTitle, taskNote);
      

      Here is sample:

      :
      :
              // Insert the task  
              //addTask_(taskTitle, TASKLIST);  
              addTask_(taskTitle, taskNote, TASKLIST);  
      
              // [Optional] Send email for every new task
              MailApp.sendEmail('ittichai@gmail.com', taskTitle, taskNote);
      
              // Set to 'done' by exchanging labels  
              thread.removeLabel(label_pending);  
              thread.addLabel(label_done);  
            }  
      :
      :
      

      In order to batch email, you can re-use the section to read all tasks and incorporate this email script.

  4. Hi Ittichai,

    Thanks, I’ve implemented the Gmail–>Google Tasks and it works great!

    Unfortunately the Google Tasks–>Gmail script doesn’t work, I’m not sure why (I’m a beginner with code). It didn’t show me any errors though.

    I probably didn’t explain myself correctly, I’m looking for the script to:

    – Know when a new task is added (either from within the Google Tasks window or my ‘GTasks’ Android app – so the new task won’t be coming from an email via your script) – and email that task to me so it appears in my inbox (because I include a ‘tag’ within each note which Gmail filters into relevant labels)

    – Read through my existing Google Tasks and for each individual task, email each task separately to me so it appears in my inbox

    Am I doing something wrong? Thanks, Adam

  5. Adam,

    I came up quickly with a script for your 2nd question. It will read all tasks in the specified task list, then send email out for each task with task title to be email’s subject, and task’s note to be email’s content. See the script here at https://ittichaicham.com/wiki/Send_All_Google_Tasks_in_a_Task_List_to_Google_GMail

    For the first question, you may have to do some research on which Gtask’s attributes you can use to identify “new”. I would think there may be the created date or last updated date attribute. So it is just a matter of using the script above and send out only date later than the updated date.

  6. Hi Ittichai,

    Fantastic thank you so much! It’s much appreciated!

    I am going to sort through my tasks so they’re all tagged properly (which might take a while) then I’ll try this script out.

    You’ve been so helpful, thanks again, Adam

  7. Hi Ittichai,

    I’ve tried the script and it seems that it works, but there also appears to be a character limit on sending each Task.

    It sent about 5 Tasks perfectly and then a task which has 495 characters caused an error in the code “Argument too large”.

    Is there a character limit on each Google Task? I read that there might be a 1000 character limit but 495 seems low. And is it possible to process the rest of the Tasks and let me know which ones were too large? (so I can send those ones individually?)

    Thanks for all your help, Adam.

    1. There may be a limit on Google’s Task Note but I think it is a lot more than 500 characters for sure. I think there may be a limit on sending email via script. You can use the debugging tool in the scripting tool to possibly find out what actually caused the error.

      Or try to limit the number of characters and see whether or not it works out for you.

      tasknotes.substring(0,300)
      
  8. It seems the problem was that the initial text paragraph was too long – which caused the whole paragraph to be used as the ‘subject’ of the email, meaning it went over whatever the character limit is for the ‘subject’ in an email.

    I’ve now got the error:

    Service invoked too many times for one day: email. (line 27, file “Code”)

    I’ll try increasing it but I thought it was 5000 times/day.

    Adam

    1. I’ve gone onto the Traffic Controls and increased the Translate API requests to 1,000 a day (if the script even uses it) and the Tasks API to 5,000 a day.

      I’ll also look for the Gmail API to see if that has been used/needs increasing.

      One problem I’ve encountered is that every time the task runs it repeats the tasks that have already been sent – so if I keep running it I’ll get duplicates of each old task every time.

      Is there a way to stop it re-sending tasks it has already sent? Thanks

      1. That’s tricky without having additional attributes like timestamp. You can try to update the Task’s title or note with a keyword (e.g., SENT) when it is first processed so it will not be be processed the next time.

  9. Hmmm thanks, yes if I could automatically add a keyword to each task that gets sent to Gmail (such as ‘alreadyprocessedthroughgoogletasks’ – long and very unlikely to be matched to other emails), I could add a filter to Gmail that deletes all emails with that keyword. Although that would still be sending all tasks again and again.

    That might work, although I’ve no idea how to do it!

  10. I don’t know how to add code. Is the a simpler way to send an email with the task in subject of gmail and have it go to gmail task?

  11. PATRICK R JEWELL

    Script works great! Thank you so much.. One question. Is there any way to make the email attach itself to the task? I like this feature when you manually add to task via Gmail, would love this to happen automatically 🙂

      1. PATRICK R JEWELL

        If you drag an email from Gmail to Google task it attaches the email and you can click on it, opening back in Gmail. Same if you use the ‘add to task ” button in Gmail.
        Was really hoping to replicate in app script.. bummer 🙁

          1. Thanks! I am playing with this now. So far not successful getting the add link to work, but I am new to task api work. Will keep trying

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top