NEW GMAIL IN INBOX : SETUP SMS ALERTS FOR NEW GMAILS IN YOUR MAILBOX
Need? or Requirement?
Well, this setup is my requirement because I don’t have 24 hours running Internet on my mobile device. Neither it is possible to repeatedly check for new mails with really slow Internet. So, it became my requirement to receive SMS alert on new mails and check mails when I feel that something important has arrived.
Of course, most of tech-giants would not feel this useful for many and much more useful reasons. For every other fellow, I will try to make this setup look, lame.
Theory? / Concept? / Procedure?
Here comes the boring part. I request you not to read this theory part further because the setup is much more easy and you will understand the things as you go.
Still, for the sake of headline, lets take this challenge too.
This setup is basically described for Gmail users. We are going to setup something which will send a SMS notification on mobile device for every new email you receive on Gmail. We will now be using any third party here in our configuration. Instead we will use a google spreadsheet script and mobile verification in google calendar account. Doing this appropriately should solve our purpose for this post. Of course you can filter the the type of mails for which you want to receive SMS alerts, but that’s a later part. One more thing, and yes it is important one that the Messages sent to your phone will be…..
FREE! FREE! FREE! FREE! FREE!!
Note: Unless you mobile network carrier charge for it.
Starting the Setup:
The number of steps are large, but simple. It is because a complete step also asks to just do a single click.
1. Login to your Gmail account, if you don’t have one, then please create (at least for trying a dummy setup).
2. Click on the gear icon visible in rightmost corner of the account. You can also refer the screens attached below every step.
3. Click on “Settings” link from the dropdown.
4. Now, from the newly loaded page, click on “Labels” menu.
5. Scroll to the bottom of the page, click on “Create new label”.
6. Name it exactly “smsMail” and the click on “Create” button from the popup box. The popup should close now.
7. Now, from the same menu on which you clicked “Labels”, its time to click on “Filters”.
Now, we will filter the type of email notifications you want to receive. Like, you want to receive only those mails which contain name “Ankit Mathur”, such filtering can be done here. However, I would be highly obliged if you make a filter with my name and receive its notification in your mobile
8. Again scroll down and reach bottom of the page.
9. Click on a link named as “Create a new filter”.
10. Now, from the new dropdown which has appeared you need to select the filter you want to make. Lets say, in the “To” textbox you fill your email id. Which will send notification for every that mail which is delivered on your email id.
11. After you have done with filter contents, click on “Create filter with this search >>” which is at the bottom of the dropdown window.
12. Now, the dropdown contents should get updated.
13. Checkmark the label saying “Apply the Label”.
14. Now, from the combo box in front of the label, select the label with exact name as “smsMail”.
15. Now, click on the blue button in the same dropdown which says “Create Filter”. The filter should be created by now.
———————————— End of settings in Mailbox ————————————
1. Now, go to google docs from the same logged-in account. If you can’t find the link, then follow here: https://docs.google.com/
2. From the left-most menu, click on red colored “Create”, a dropdown will appear. Select “Spreadsheet” from it.
3. Now, from the spreadsheet menu, select “Tools” and go to “Script Editor”.
4. A new page with a popup will open up. From left menu, select “Spreadsheet”.
5. You will be redirected to a new page for writing some code. Don’t worry, I will provide you the code for it
6. In the code tab named as “Code.gs”, select the prewritten code and brutally delete it. Blank the whole window and color it from the white blood of codes.
7. For the code, you can copy it from this link too: Github Link for the Code.
Also you can paste the below code in the same window
(but copying this below code may conflict some single quote issues. Better if you copy the code from above gist link):
(but copying this below code may conflict some single quote issues. Better if you copy the code from above gist link):
function smsMail()
{
try
{
var label = GmailApp.getUserLabelByName(‘smsMail’);
var threads = label.getThreads();
var now = new Date().getTime();
var cal=getCalendar();for(i in threads)
{cal.createEvent(threads[i].getFirstMessageSubject()+”: “+threads[i].getMessages()[0].getFrom(),new Date(now+60000),
new Date(now+60000)).removeAllReminders().addSmsReminder(0);}
label.removeFromThreads(threads);
}
catch(err)
{
Logger.log(“Error Occured”+ err.toString());
}
}function getCalendar()
{
try
{
var label = GmailApp.getUserLabelByName(‘smsMail’);
var threads = label.getThreads();
var now = new Date().getTime();
var cal=getCalendar();for(i in threads)
{cal.createEvent(threads[i].getFirstMessageSubject()+”: “+threads[i].getMessages()[0].getFrom(),new Date(now+60000),
new Date(now+60000)).removeAllReminders().addSmsReminder(0);}
label.removeFromThreads(threads);
}
catch(err)
{
Logger.log(“Error Occured”+ err.toString());
}
}function getCalendar()
{
try
{
var cal=CalendarApp.getOwnedCalendarsByName(“smsMail”)[0];
try
{
var cal=CalendarApp.getOwnedCalendarsByName(“smsMail”)[0];
if (!cal)
{
cal=CalendarApp.createCalendar(“smsMail”);
return cal;
}
{
cal=CalendarApp.createCalendar(“smsMail”);
return cal;
}
else
{
return cal;
}
}
catch(e)
{
Logger.log(“Error Occured”+ e.toString());
}
{
return cal;
}
}
catch(e)
{
Logger.log(“Error Occured”+ e.toString());
}
}
function onOpen()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Authorize", functionName: "authorize"},
{name: "Stop SMS alerts", functionName: "stopsmsalerts"}
];
ss.addMenu(“Gmail SMS Alerts”, menuEntries);
}
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Authorize", functionName: "authorize"},
{name: "Stop SMS alerts", functionName: "stopsmsalerts"}
];
ss.addMenu(“Gmail SMS Alerts”, menuEntries);
}
function authorize(){}
function stopsmsalerts()
{
var allTriggers = ScriptApp.getScriptTriggers();
{
var allTriggers = ScriptApp.getScriptTriggers();
for(var i=0; i < allTriggers.length; i++)
ScriptApp.deleteTrigger(allTriggers[i]);
ScriptApp.deleteTrigger(allTriggers[i]);
Browser.msgBox(“Success”, “You will not be getting SMS alerts anymore.”,Browser.Buttons.OK);
}
}
8. Now, from the window menu, click on “File” and save the file with name exactly “smsMail”.
9. Now, from the same window menu, click on “Run” and from the dropdown select “authorize”.
10. Now, close this window and go to the spreadsheet. Close the spreadsheet and reopen it. You will be able to see a new menu as “Get SMS Alerts”.
11. Click on it and from the dropdown select “Authorize”.
12. Close the spreadsheet too.
————- Here we are done with the spreadsheet configuration ————
1. Go to google calendar from the same logged-in account.
2. From the rightmost gear icon, click on “Settings”.
3. Now, depends on you whether you want calendar alerts on all of the checks available or only on mobile. So, select wisely.
For now, lets select “SMS” only. If your mobile is not connected to google calendar then, it is necessary for you to connect it because without it you won’t receive SMS on your mobile device.
To connect your mobile device with calendar, enter your mobile number in the corresponding textbox for “SMS”. Then click the corresponding button to it. Google will send you a code which you will need to enter in the same textbox in which you entered your mobile number (Notice that the textbox has gone blank by now). Again click on the corresponding button to confirm.
By now, you should be done with the mobile number connection.
NOTE: This is the most important step because if the mobile number doesn’t get configured in calendar then you won’t receive SMS anyhow from the script.
Moving to next step, please let me know if you can’t configure the mobile number here. We will try it again, together.
4. Now from the same gearbox in the right corner, go to “Settings”.
5. You will be shown “General” tab. Please recheck your country details, timezone details and other details. Make sure they are correct for your location.
6. Now, from the tabs menu, go to “Calendars” tab.
7. Here, you should see “smsMail” in your calendar list. Check mark in front of it, save and then and click on “Reminders and Notifications”.
8. Now, check mark all the types of notifications you wish to receive as SMS.
9. Now, save and return to calendar settings screen.
10. Now, move to “Mobile Setup” tab and make sure your mobile number is shown verified there. Else, verify it there.
11. Now, you need to reopen the same spreadsheet which you used to copy-paste the script. Under tools menu, select “Script Editor”.
12. Now, in the script window’s menu click on “Resources” and select “Current project’s triggers”. Add a new trigger here according to the frequency you wish to receive the mails.
13. You are done with the setup here. Send a test mail to yourself and a message about same should beep on your mobile device. Else, let’s discuss here. We together will try to solve the issue, chill! :)
SOURCES: INTERNET