Skip to content

Instantly share code, notes, and snippets.

@pen
Last active March 24, 2019 15:04
Show Gist options
  • Save pen/7591697a457e27238e0a186fd6bfaa12 to your computer and use it in GitHub Desktop.
Save pen/7591697a457e27238e0a186fd6bfaa12 to your computer and use it in GitHub Desktop.
// トリガー設定で1時間毎ぐらいに起動する
function myFunction() {
threads = GmailApp.search('label:kin is:unread') // ラベルはフィルタ設定でつける
if (threads.length == 0) {
return
}
message = threads[0].getMessages()[0] // どの一通でも通知されれば見にいくので
text = "メールだよ\n" + message.getFrom() + "\n「" + message.getSubject() + "」"
UrlFetchApp.fetch(
'https://notify-api.line.me/api/notify',
{
'method': 'POST',
'payload': 'message=' + text,
'headers': { 'Authorization': 'Bearer __LINE_TOKEN__' } // 自分のに置換
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment