I am working on SMS notification each time I receive an email that meets certain criteria; I decided to use Google App Scripts for this.
I have been inspired in particular by the following article https://developers.google.com/apps-script/articles/gmail_filter_sms. I also checked the related question in StackOverflow SMS Alerts for Important Mails in Gmail.
I improved the original script from developers.google.com by cleaning up the events the next time the script is run (I was receiving the SMS alerts each time the script is run). The script is currently working by using the label 'SendText' and creating events in calendar 'AlertSMS'.
However the SMS I receive only contain the subject and author of the email: I need to display the content of the email (or at least a part of it). I tried with no luck to add it to the description of the event. Anybody got an idea on how to do it?
Hereunder, the code of my script:
function sendText() {
var now = new Date().getTime();
// Delete old events
var events = CalendarApp.openByName('AlertSMS').getEvents(new Date('January 1, 2010 EST'), new Date(now-30000));
for (i in events) {
events[i].deleteEvent();
}
// Get list of emails to set alert for
var label = GmailApp.getUserLabelByName('SendText');
var threads = label.getThreads();
// Create new events for emails alert
for(i in threads){
var message=threads[i].getMessages()[0];
CalendarApp.openByName('AlertSMS').createEvent('[SMS] '+threads[i].getFirstMessageSubject()+' -from- '+message.getFrom(),
new Date(now+60000), new Date(now+60000), { description:message.getBody() }).addSmsReminder(0);
}
label.removeFromThreads(threads);
}
You can send email using MailApp. sendEmail() function like this: MailApp. sendEmail({ to: email, subject: "This is a test email", htmlBody: message });
If you know JavaScript, you can use Google Apps Script to add features to many Google products including Gmail. If you've used Office scripting, the idea is the same, although obviously the implementation is very different.
Whenever you get a new email sent to your Gmail, you can now get a push notification sent to your mobile device. You will need to install the Power Automate app for iOS or Android to use this flow.
You can use services such as (the completely free) IFTTT or (the somewhat free) Zapier to trigger an SMS action upon receiving emails matching a criteria.
Here are some IFTTT "recipes" which connect GMail to SMS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With