Gmail SMS Notification Using Google Apps Scripts: How do I display email content?

I work on an SMS notification every time I receive an email that meets certain criteria; I decided to use Google application scripts for this.

I was inspired in particular by the following article https://developers.google.com/apps-script/articles/gmail_filter_sms . I also checked a related question in StackOverflow SMS Alerts for important emails in Gmail .

I improved the original script from developers.google.com by clearing events the next time the script was run (I received SMS alerts every time the script was run). Currently, the script works using the "SendText" label and creating events in the "AlertSMS" calendar.

However, the SMS messages I receive contain only the subject and the author of the email: I need to display the contents of the email (or at least part of it). I did not dare to add it to the description of the event. Has anyone figured out how to do this?

Next, 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); } 
+6
source share
2 answers

You can use services such as (free) IFTTT or (somewhat free) Zapier to trigger an SMS action when you receive emails matching the criteria.

Here are some IFTTT recipes that connect GMail with SMS.

+5
source

You really don't need a hacker calendar to send arbitrary text messages to yourself - every mobile provider has an email to a text gateway. For example, for verizon, its 5551234567@vtext.com (replace your phone number) and there is a similar one for other operators. Just use GmailApp to email these numbers and you can send whatever you want.

0
source

All Articles