Difference between revisions of "Send All Google Tasks in a Task List to Google GMail"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 18: Line 18:
 
function main() {
 
function main() {
 
    
 
    
     //Get the task list items
+
     // Get the task ID defined in TASKLIST
 
     var tasklistid = getTasklistId_(TASKLIST)
 
     var tasklistid = getTasklistId_(TASKLIST)
 +
   
 +
    // Get all tasks in the task list
 
     var tasks = Tasks.Tasks.list(tasklistid).getItems();
 
     var tasks = Tasks.Tasks.list(tasklistid).getItems();
    var alltasks = "";
+
 
 
     for(var i in tasks){
 
     for(var i in tasks){
 
         var tasktitle = tasks[i].getTitle();
 
         var tasktitle = tasks[i].getTitle();
         alltasks = alltasks + tasktitle + "\n";
+
         var tasknotes = tasks[i].getNotes();
    }
+
        MailApp.sendEmail('ittichai@gmail.com', tasktitle, tasknotes);
 
+
 
    MailApp.sendEmail('ittichai@gmail.com', "All Pending Tasks", alltasks);
+
    } 
 
 
 
}
 
}
 +
  
 
</pre>
 
</pre>
 +
 +
* See this note to understand what needs to be done to run this script - http://ittichaicham.com/wiki/Create_Google_Tasks_by_sending_email_to_Google_GMail
 +
 +
[[Category: Others]]

Latest revision as of 13:12, 23 March 2014


// Constant
TASKLIST = "Ittichai's list";  
// -----------------------------------------------------  

function getTasklistId_(tasklistName) {  
      var tasklistsList = Tasks.Tasklists.list();  
      var taskLists = tasklistsList.getItems();  
      for (tl in taskLists) {  
        var title = taskLists[tl].getTitle();  
        if (title == tasklistName) {  
          return taskLists[tl].getId();  
        }  
      }  
    }  

function main() {
  
    // Get the task ID defined in TASKLIST
    var tasklistid = getTasklistId_(TASKLIST)
    
    // Get all tasks in the task list
    var tasks = Tasks.Tasks.list(tasklistid).getItems();

    for(var i in tasks){
         var tasktitle = tasks[i].getTitle();
         var tasknotes = tasks[i].getNotes();
         MailApp.sendEmail('ittichai@gmail.com', tasktitle, tasknotes);

    }  
}