这是调用masseges的片段:
function getEmails(max) {
var threads = GmailApp.search("in:inbox", 0, 500);
var myMsgs = "<table>";
for (var i = 0; i < threads.length; i++) {
myMsgs+= "<tr><td>"+ threads[i].getFirstMessageSubject() +"</td></tr>"
}
myMsgs += "</table>"
return myMsgs;
}
这是在侧边栏中显示消息的功能:
function getEmails() {
clearDom();
var mySelector = document.getElementById("myselector");
var valueSelectede = mySelector.options[mySelector.selectedIndex].value;
google.script.run
.withSuccessHandler(getEmailsCallback)
.getEmails(valueSelected);
}
这是下拉列表:
<div class="button-bar" style="padding: 10px;background-color:#EEEEEE;width:100%">
<button id="startButton" class="blue" onclick="getEmails()">Get message(s)</button>
<button id="groupsButton" class="red" onclick="getGroups()">Get Groups</button>
<select id="myselector">
<option value=2 selected="selected">2</option>
<option value=10>10</option>
<option value=25>25</option>
<option value=50>50</option>
</select>
</div>
如何在用户选择号码2,10,25或50中仅显示2,10,25或50条消息 如果您愿意花时间仔细阅读我的问题并帮助我解决它,将不胜感激
答案 0 :(得分:0)
如果有人需要,这是新的工作代码
function getEmails() {
clearDom();
var mySelector = document.getElementById("myselector");
var valueSelected = mySelector.options[mySelector.selectedIndex].value;
google.script.run
.withSuccessHandler(getEmailsCallback)
.getEmails(valueSelected);
}
导入电子邮件的功能希望有帮助
答案 1 :(得分:-1)
似乎是这样的:
function getEmails(start, max) {
var threads = GmailApp.search("in:inbox", start, max);
var myMsgs = "<table>";
for (var i = 0; i < threads.length; i++) {
myMsgs+= "<tr><td>"+ threads[i].getFirstMessageSubject() +"</td></tr>"
}
myMsgs += "</table>"
return myMsgs;
}
<div class="button-bar" style="padding: 10px;background-color:#EEEEEE;width:100%">
<button id="startButton" class="blue" onclick="getEmails(0, Number(document.getElementById('myselector').value))">Get message(s)</button>
<button id="groupsButton" class="red" onclick="getGroups()">Get Groups</button>
<select id="myselector">
<option value=2 selected="selected">2</option>
<option value=10>10</option>
<option value=25>25</option>
<option value=50>50</option>
</select>
</div>
我添加了参数start,因为您可能希望开发显示分页的方案。