我正在尝试获取一个人收到电子邮件的次数,因此我可以跟踪潜在客户,例如
user@domain.com was emailed 5 times
user2@domain.com was emailed 3 times
从阅读文档我无法想出这个
这可能吗?
编辑:
function myFunction(e) {
e = "someemail@gmail.com";
var threads = GmailApp.search("to:" + e + "");
var count = 0;
for (var i = 0; i < threads.length; i++) {
count++;
}
Logger.log(count) //1
}
这给了我线程但没有多少条消息
答案 0 :(得分:0)
我认为你使用search()找到发送的项目是正确的。这是我用来扫描收件箱中所有未读电子邮件以及电子邮件处理的片段。你会想要类似的东西:
var totalThreads = GmailApp.getInboxThreads().length
// Read in READ_AT_ONCE pages of email at a time
for (var pageindex = 0; pageindex < totalThreads; pageindex += READ_AT_ONCE) {
var threads = GmailApp.getInboxThreads(pageindex, READ_AT_ONCE)
var msgs = GmailApp.getMessagesForThreads(threads)
var numThreads = threads.length
// Read in all the threads in the batch
for (var threadIndex = 0; threadIndex < numThreads; threadIndex++) {
var numMsgs = msgs[threadIndex].length
// Process each msg in the thread
for (var msgIndex = 0; msgIndex < numMsgs; msgIndex++) {
var msg = msgs[threadIndex][msgIndex]
if (!msg.isUnread() || msg.isInTrash()) {
continue
}
Email_.processMsg(msg)
} // for each msg
} // for each thread
} // for each batch