我需要生成一个关于邮件列表和发件人的报告,我可以提取信件的主题,但不明白如何获取每封信的发件人地址,报告结果是:
主题:你好来自:frank@gmail.com
主题:你的购物篮来自:jerry@facebook.com
function myFunction() {
var emailAddress = Session.getActiveUser().getEmail();
var threads = GmailApp.getInboxThreads();
var output = ContentService.createTextOutput();
for (var i = 0; i < threads.length; i++) {
output.append(threads[i].getFirstMessageSubject()+" from:"+'\n');
}
GmailApp.sendEmail(emailAddress,"Mail Report", output.getContent()
);
}
更新
谢谢你的回答,解决方法很简单
function myFunction() {
var emailAddress = "example@email.com" ;
var threads = GmailApp.getInboxThreads();
var messages = threads[0].getMessages();
var senderEmail = messages[0].getFrom();
var output = ContentService.createTextOutput();
for (var i = 0; i < threads.length; i++) {
messages = threads[i].getMessages()
senderEmail = messages[0].getFrom();
output.append(i + ". " + threads[i].getFirstMessageSubject()+" from:"+ senderEmail + '\n');
}
GmailApp.sendEmail(emailAddress,"Mail Report", output.getContent()
);
}
示例结果:
- 电子邮件验证 - 堆栈溢出来自:堆栈溢出
- 项目更新 #10:Double Fine 和 2 人制作的 Double Fine Adventure 来自:Kickstarter