kode untuk monitor email dari google app script
function monitorEmails() {
var inbox = GmailApp.getInboxThreads();
//var label = GmailApp.getUserLabelByName('Inbox');
//var doneLabel = GmailApp.getUserLabelByName('executed');
//var cmds = label.getThreads();
var max = Math.min(inbox.length,5);
for( var i = 0; i < max; ++i ) {
var email = inbox[i].getMessages()[0];
var subject = email.getSubject();
var sender = email.getFrom();
//you may need to do extra parsing here, depending on your usage
if(email.isUnread())
{
Logger.log("["+sender+"]:"+subject);
sendSMS(subject);
email.markRead();
}
}
}
function sendSMS(message)
{
var cal = CalendarApp.getDefaultCalendar();
var waktu = new Date();
waktu.setMinutes ( waktu.getMinutes() + 12 );
var selesai = new Date();
selesai.setHours(selesai.getHours() + 1);
cal.createEvent(message , waktu, selesai, {location:''});
}
wah berguna banget nih, thanks bung arfan !
ReplyDelete