使用Google Apps脚本的Gmail短信通知:如何显示电子邮件的内容? [英] SMS notification for Gmail using Google Apps Scripts: how to display content of the email?

查看:192
本文介绍了使用Google Apps脚本的Gmail短信通知:如何显示电子邮件的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每次收到符合特定条件的电子邮件时都会收到短信通知;我决定为此使用Google应用程序脚本。



以下文章 https://developers.google.com/apps-script/articles/gmail_filter_sms 。我还检查了StackOverflow中的相关问题 Gmail中重要邮件的短信提醒



我通过在下次运行脚本时清理事件,改进了developers.google.com的原始脚本(每次收到SMS警报脚本运行)。该脚本目前正在使用标签SendText并在日历AlertSMS中创建事件。 然而,我收到的短信只包含电子邮件的主题和作者:我需要显示电子邮件的内容(或至少一部分)。我试图将它添加到事件的描述中。有人知道如何做到这一点吗?



以下是我的脚本代码:

  function sendText(){
var now = new Date()。getTime();

//删除旧事件
var events = CalendarApp.openByName('AlertSMS').getEvents(new Date('January 1,2010 EST'),new Date(now-30000) );
for(i in events){
events [i] .deleteEvent();
}

//获取电子邮件列表,为
设置警报var label = GmailApp.getUserLabelByName('SendText');
var threads = label.getThreads();

//为电子邮件创建新事件提醒
(i在线程中){
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);
}


解决方案

(完全免费) IFTTT 或(有点免费) Zapier 在收到符合条件的电子邮件时触发短信操作。 b
这里是一些将GMail连接到SMS的IFTTT食谱。


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 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.

这篇关于使用Google Apps脚本的Gmail短信通知:如何显示电子邮件的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆