使用 google 脚本自动获取电子邮件机器人
Auto get Email bot with google scripts
我正在制作一个获取第一封电子邮件并打印出来的机器人。这是我目前所拥有的:
.gs
function doGet() {
return HtmlService.createHtmlOutputFromFile('index')
}
.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function mail() {
var thread = GmailApp.getInboxThreads(0,1)[0]; // Get first thread in inbox
thread.getMessages()[0];
}
function text() {
var list = document.getElementsByClassName("example")[0];
list.getElementsByClassName("child")[0].innerHTML = mail();
}
</script>
</head>
<body>
<ul class="example">
<li class="child">Coffee</li>
</ul>
<button onclick="text()">Try it</button>
</body>
</html>
请告诉我哪里出了问题,如果您需要任何其他信息,请发表评论
html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function text() {
google.script.run
.withSuccessHandler(function(whatever){
//do whatever your want with whatever here
})
.mail()
}
</script>
</head>
<body>
<ul class="example">
<li class="child">Coffee</li>
</ul>
<button onclick="text()">Try it</button>
</body>
</html>
Code.gs:
function mail() {
var thread = GmailApp.getInboxThreads(0,1)[0]; // Get first thread in inbox
thread.getMessages()[0];
//.......
return whatever;
}
这是另一个例子:
我正在制作一个获取第一封电子邮件并打印出来的机器人。这是我目前所拥有的:
.gs
function doGet() {
return HtmlService.createHtmlOutputFromFile('index')
}
.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function mail() {
var thread = GmailApp.getInboxThreads(0,1)[0]; // Get first thread in inbox
thread.getMessages()[0];
}
function text() {
var list = document.getElementsByClassName("example")[0];
list.getElementsByClassName("child")[0].innerHTML = mail();
}
</script>
</head>
<body>
<ul class="example">
<li class="child">Coffee</li>
</ul>
<button onclick="text()">Try it</button>
</body>
</html>
请告诉我哪里出了问题,如果您需要任何其他信息,请发表评论
html:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function text() {
google.script.run
.withSuccessHandler(function(whatever){
//do whatever your want with whatever here
})
.mail()
}
</script>
</head>
<body>
<ul class="example">
<li class="child">Coffee</li>
</ul>
<button onclick="text()">Try it</button>
</body>
</html>
Code.gs:
function mail() {
var thread = GmailApp.getInboxThreads(0,1)[0]; // Get first thread in inbox
thread.getMessages()[0];
//.......
return whatever;
}
这是另一个例子: