google apps script - Count number of email sent to a person -


i trying number of times person has been sent email, can keep track of leads, example

user@domain.com emailed 5 times user2@domain.com emailed 3 times 

from reading docs cannot figure 1 out

is possible?

edit:

 function myfunction(e) {    e = "someemail@gmail.com";   var threads = gmailapp.search("to:" + e + "");   var count = 0;   (var = 0; < threads.length; i++) {        count++;         }    logger.log(count) //1 } 

this gives me threads no number of messages

i think on right lines using search() find sent items. snippet use scan through unread emails in inbox, , processing email. you'll want similar:

  var totalthreads = gmailapp.getinboxthreads().length   // read in read_at_once pages of email @ time   (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 threads in batch     (var threadindex = 0; threadindex < numthreads; threadindex++) {       var nummsgs = msgs[threadindex].length                // process each msg in thread       (var msgindex = 0; msgindex < nummsgs; msgindex++) {         var msg = msgs[threadindex][msgindex]         if (!msg.isunread() || msg.isintrash()) {           continue         }         email_.processmsg(msg)           } // each msg     } // each thread           } // each batch 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -