Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function sendLineNotifyCalender(){
var token = ["YOUR_TOKEN"];
var today = new Date();
var myEvents = CalendarApp.getDefaultCalendar().getEventsForDay(today);
var bodyItem = [ "本日の予定" ];
//送信するメッセージ用
var message = '\n';
//予定の数だけループする
for(var i=0;i<myEvents.length;i++){
var strTitle = myEvents[i].getTitle(); //イベントのタイトル
var strStart = Utilities.formatDate(myEvents[i].getStartTime(), 'JST', 'HH:mm'); //イベントの開始時刻
var strEnd = Utilities.formatDate(myEvents[i].getEndTime(), 'JST', 'HH:mm'); //イベントの終了時刻
if (strStart === '00:00' & strEnd === '00:00'){
message +='予定:'+strTitle+'\n'
+'終日\n\n';
}else{
message +='予定:'+strTitle+'\n'
+'開始時間:'+strStart+'\n'
+'終了時間:'+strEnd+'\n\n';
}
}
UrlFetchApp.fetch("https://notify-api.line.me/api/notify",
{
"method" : "post",
"payload" : "message=" + message,
"headers" : {"Authorization" : "Bearer "+ token}
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment