Wednesday, April 25, 2012

Get SMS notification for emails at GMail


Romain Vialard is a Google Apps Script Top Contributor. He has contributed interesting articles and blog posts about Apps Script. - Jan Kleinert
I just had to share this finding with all of you. Now you can get SMS alert or notifications for important emails at GMail.


Just follow the steps described at the below link:
https://developers.google.com/apps-script/articles/gmail_filter_sms#section1
or,
Just follow the steps below(copied from above link):


  1. In Google Calendar, register your mobile phone to enable SMS notifications.
  2. In Gmail, create a new label named 'Send text'.
  3. In Gmail, create a filter to apply the label 'Send text' to important emails. For example, you may want consider emails from your boss containing the word 'urgent' as important.
  4. Send an email to yourself to try this filter.
  5. In Google Docs, open a new spreadsheet.
  6. Choose the menu Tools > Script Editor.
  7. Copy and paste the following script:
    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);
    }
  8. Save the script.
  9. Click the Run icon. A pop-up opens asking you for your authorization to access the Gmail and Google Calendar services.
  10. Click the Authorize button.
  11. Click the Run icon again.
  12. After one minute, you should receive a text on your mobile device, containing the subject of the email you wrote and sent in Step 4.

23 comments:

putracl said...

Give me a video of this tutorial please

Anonymous said...

Brilliant!

Anonymous said...

...Alas, not very practical (as the link implies).

Anonymous said...

Nice. But Not Work Me. Please Screen Shot Add. It s Very Impotent Article .Thank

Ashwani Chohan said...

Nice. But Not Work Me. Please Screen Shot Add. It s Very Impotent Article .Thank

Mohammad Ashik Elahi said...

@Ashwani Chohan: All of my friends and colleagues are using sms feature of google, using this procedure.

I think adding screen-shots would unnecessary.

With Regards
Ashik

Ashwani Chohan said...

Thanks !I Am Waiting Sir , and robot Code Very difficult. I Try 5 Time . Make Post.Thanks !!

Anonymous said...

thanks bro its working fine, you are greate...

Shrinivas said...

Great tip.. I was searching for this from long time and got the solution here..

Ranjith S said...

The best way to get gmail alerts on mobile via sms is to use 3rd party service called weekwill.com. I have been using it since long time now and its just works perfect for me. Whenever I get email in my gmail inbox, I get sms instantly. Its great. It doesn't require internet connection in your phone or any 3G. Try it.

Girish said...

Hi
This is great!
But do you have to keep pressing run from excel for the notifications to go?

Mohammad Ashik Elahi said...

Hi Girish,

You have to run the code one time and save it. That's it...Nothing more.

Regards
Ashik

Admin said...

Getting error as :

Illegal character. (line 2)

Anonymous said...

It's only sending the subject of the mail. Is it possible to send whole mail?

Anonymous said...

Thanks, works great. However I seem to get between 2-4 sms notification for each email. Is there a way to specify for just 1 sms per email?
Many thanks.

Mohammad Ashik Elahi said...

@Anonymous:
I think it's possible to get the whole message.
Try changing the script by replacing "getFirstMessageSubject()" with "getMessages()".

REF: https://developers.google.com/apps-script/service_gmail

Anonymous said...

You are missing the most important thing to make it work.. ( from your ref link )

Using a time-driven trigger

A time-driven trigger is useful to check the label ‘Send text’ periodically and send you a text each time a new email is found with this label. The function sendText can be automatically triggered every day, hour or even minute.

To install a trigger:

In the script editor, open the Resources menu and click Current script's triggers... The Current script's triggers dialog opens.
Click on the link that says No triggers set up. Click here to add one now. A dialog opens, asking you to set up triggers.
Ensure that the function sendText and the event 'Time-driven' are selected.
Select the appropriate time depending on your needs. The script can be automatically triggered every minute, hour, day, etc.
Click the Save button.

Simran Kohli said...

nyc one..works good...but we get 2-4 msgs for an email..any way to get only 1?

Anonymous said...

So I'm not the only one what receives 2 or 3 notifications. First I thought it was because I modified the script so it creates the events in a secondary calendar, because I didn't want to overcrowd my calendar with these notifications (I use multiple calendars and sync them with my e-mail client). My script looks like this:

function sendText() {
var label = GmailApp.getUserLabelByName('SMS');
var threads = label.getThreads();
var now = new Date().getTime();
var cal = CalendarApp.getOwnedCalendarById('id@group.calendar.google.com');
for(i in threads){
cal.createEvent('Email- '+threads[0].getFirstMessageSubject(),
new Date(now+60000),
new Date(now+60000)).addSmsReminder(0);
}
label.removeFromThreads(threads);
}

You must change the calendar ID with your own ID.

Anonymous said...

Hi,

thanks for this article.

Regards,
Rafal
http://alert-please.com

Anonymous said...

Google Script will send you an email notification alert if you have not received an expected email message in xx number of days.
http://baumbach.com/google-script/

Technoideas said...

Video Tutorial
www.youtube.com/watch?v=jES0lh5VJMA‎

rplis said...

Very interesting solution. Personally I use alert-please.com. It is not for free but it works quite good.