2016-07-06 79 views
-1

我试图让一个人已发送的邮件的次数,这样我就可以跟踪线索,例如伯爵号发送到一个人

[email protected] was emailed 5 times 
[email protected] was emailed 3 times 

从阅读文档我不能找出这一个

这可能吗?

编辑:

function myFunction(e) { 

    e = "[email protected]"; 
    var threads = GmailApp.search("to:" + e + ""); 
    var count = 0; 
    for (var i = 0; i < threads.length; i++) { 
     count++;  
    } 
    Logger.log(count) //1 
} 

这给我的线程,但没有数量的消息

+0

看看在[GMailApp(https://developers.google.com/apps-script/reference/gmail/gmail-app),并把一些代码,您张贴所以这个问题有点更具体。 –

+0

我加了我的代码 –

回答

0

我觉得你是在使用搜索()来查找已发送的邮件右线。这是我用来扫描收件箱中所有未读电子邮件以及处理电子邮件的代码片段。你会希望类似的事情:

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