Sunday 17 March 2013

Get your NON-SMART phone to receive Gmail notifications!

Do you not have a smart phone? But do you want to get  notifications when you receive important emails in Gmail? Google Apps script allows you to interact between various Google products (in our case, Gmail and Calendar) and third party services.

Here is what you need to do to convert your dumb phone into an email notifier:

Step 1:  Register your mobile to receive SMS via Google Calendar.  Here is how to do it. Done? Great.

Step 2:  Create a new Label in your Gmail account. Here is how you create a label. All good? 

Step 3:   Create a Filter, to apply the label (which you created in the previous step) to this filter. Here is how your create a filter. Alright then.

Step 4:  Go to script.google.com. Select Blank Project.

Step 5:  Copy and paste this following piece of code: 

function sendText() {
  var label = GmailApp.getUserLabelByName('Send text');
  var threads = label.getThreads();
  var now = new Date().getTime();
  for(i in threads){
    CalendarApp.createEvent('IMP- '+threads[0].getFirstMessageSubject(),
                            new Date(now+60000),
                            new Date(now+60000)).addSmsReminder(0);
  }
  label.removeFromThreads(threads);
}

# This checks for emails under the label "Send text" and if any present, adds an event with SMS reminder to Google Calendar after one minute.  

Step 6:  Now save your script and run it. It will ask for authorization. Grant the access. After one minute, you will get an SMS if you have received any email labelled as "Send text". Pretty cool, right?

Just a little more.. 
You can automate this process by setting up triggers for your script. Click the "Resources" tab (which is above your workspace) and add a trigger (minute/hourly/daily/weekly/monthly). 

And now you're done! :-)



No comments:

Post a Comment

ShareThis