gpt4 book ai didi

email - 如何获取发件人的电子邮件地址

转载 作者:行者123 更新时间:2023-12-04 18:18:11 27 4
gpt4 key购买 nike

我需要生成一份关于消息列表和一封信件发件人的报告,我可以提取信件的主题,但不明白如何获取每封信件的发件人地址,报告结果是:

主题:你好 来自: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()

);
}

示例结果:

  1. 电子邮件验证 - Stack Overflow 来自:Stack Overflow
  2. 项目更新 #10:Double Fine 和 2 Player Productions 的 Double Fine Adventure 来自:Kickstarter

最佳答案

如果我明白你想要做什么,那么我相信你可以从线程中获取消息,然后从消息中获取发件人

var threads = GmailApp.getInboxThreads();
var messages = threads[0].getMessages();
var senderEmail = messages[0].getFrom();

关于email - 如何获取发件人的电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11297182/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com