-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifyGarbageDayForCw.gs
More file actions
37 lines (29 loc) · 1.04 KB
/
notifyGarbageDayForCw.gs
File metadata and controls
37 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function notifyGarbageDayForCw(){
// 最新1件のみ処理を行う
// NOTE: 処理終了後、対象メールを既読化するので、そもそも未読が1件したない想定
var thds = GmailApp.search("label:ゴミ is:unread");
// 対象メールなしなら終了
if (!thds || thds.length === 0) { return; }
var cwMsg = '[info]--- [自動通知: ゴミの日お知らせ] ---\n\n';
// 処理
for(var n in thds){
var thd = thds[n];
var msgs = thd.getMessages();
for(m in msgs){
var msg = msgs[m];
var date = msg.getDate();
var body = msg.getBody();
var id = msg.getId();
cwMsg += body + '[/info]';
}
// 既読化
thd.markRead();
// 1件処理して終わり
break;
}
// ChatWorkに送信
var dummyRoomId = 9999999999;
var client = ChatWorkClient.factory({token: 'xxxxxxxx'});
// TODO: check your chatwork
// client.sendMessage({room_id: dummyRoomId, body: cwMsg});
}