-
-
Save cesardv/4c2c4d6875f56fb14a3d1920c869daed to your computer and use it in GitHub Desktop.
Revisions
-
siygle revised this gist
Mar 21, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ function processInboxToSheet() { var content = messages[0].getPlainBody(); // implement your own parsing rule inside if (content) { var tmp; tmp = content.match(/Name:\s*([A-Za-z0-9\s]+)(\r?\n)/); -
siygle created this gist
Mar 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ function processInboxToSheet() { //var threads = GmailApp.getInboxThreads(); // Have to get data separate to avoid google app script limit! var start = 0; var threads = GmailApp.getInboxThreads(start, 100); var sheet = SpreadsheetApp.getActiveSheet(); var result = []; for (var i = 0; i < threads.length; i++) { var messages = threads[i].getMessages(); var content = messages[0].getPlainBody(); if (content) { var tmp; tmp = content.match(/Name:\s*([A-Za-z0-9\s]+)(\r?\n)/); var username = (tmp && tmp[1]) ? tmp[1].trim() : 'No username'; tmp = content.match(/Email:\s*([A-Za-z0-9@.]+)/); var email = (tmp && tmp[1]) ? tmp[1].trim() : 'No email'; tmp = content.match(/Subject:\s*([A-Za-z0-9\s]+)(\r?\n)/); var subject = (tmp && tmp[1]) ? tmp[1].trim() : 'No subject'; tmp = content.match(/Comments:\s*([\s\S]+)/); var comment = (tmp && tmp[1]) ? tmp[1] : 'No comment'; sheet.appendRow([username, email, subject, comment]); Utilities.sleep(500); } } };