2016-07-06 84 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