-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.gs
40 lines (37 loc) · 1.04 KB
/
code.gs
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
38
39
40
function sendSlack(text)
{
var jsonData =
{
"username" : "kinQ-bot",
"icon_emoji": "email",
"text" : text
};
var payload = JSON.stringify(jsonData);
var options =
{
"method" : "post",
"contentType" : "application/json",
"payload" : payload
};
Logger.log(text);
UrlFetchApp.fetch(slackApiUrl, options);
}
function Debug(){
var date = new Date()
Logger.log(Utilities.formatDate(date, "JST", "MM/dd (E) HH:mm"))
}
function myFunction() {
var threads = GmailApp.search("KinQ.jp is:unread",0,1)
var messages = GmailApp.getMessagesForThreads(threads);
if (messages.length > 0){
var message = messages[0]
message[0].markRead()
var body = message[0].getPlainBody()
var subject = message[0].getSubject()
var date = Utilities.formatDate(message[0].getDate(), "JST", "MM/dd (E) HH:mm")
if (!body.match(/田村/)){
Logger.log("*Subject:* "+subject+"\n*Date:*"+date+"\n*body*\n>>>"+body)
sendSlack(" *Subject:* "+subject+"\n *Date:* "+date+"\n *body* \n>>>"+body)
}
}
}