Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9843

Is there a variable I can use to call a senders name?

$
0
0

I built a script for auto replying...

function autoReply() {  var interval = 5;        //  if the script runs every 5 minutes; change otherwise  var daysOff = [6,0];   // 1=Mo, 2=Tu, 3=We, 4=Th, 5=Fr, 6=Sa, 0=Su var date = new Date();     var day = date.getDay();     // get the current hour     var currenthour = date.getHours();     // define the work-hours start and end hours     var starthour= 7;     var endhour = 17;   var label = GmailApp.getUserLabelByName("autoresponded");if ((daysOff.indexOf(day) !=-1) ||(daysOff.indexOf(day) ==-1 && !(currenthour >=starthour && currenthour <=endhour))) {    var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;    var threads = GmailApp.search('is:inbox label:myfilteringlabel !label:autoresponded after:'+ timeFrom);    for (var i = 0; i < threads.length; i++) {      var message = threads[i].getMessages()[0];      if (message.getFrom().indexOf("myemail@gmail.com") < 0 && message.getFrom().indexOf("no-repl") < 0 && message.getFrom().indexOf("bounce") < 0 && message.getFrom().indexOf("spam") < 0) {        threads[i].reply("", {htmlBody: "<p>blah blah</p>", from: 'user@email.com', name: 'User'});}        label.addToThread(threads[i]);      }    }  }

Can anyone tell me how I might insert the senders "FROM" name into the body? Is there a variable I can call here?

Note: I'm aware this may not always accurately portray their name btw ;)

EDIT: getFrom() is great, but i'd love to pull only the given name


Viewing all articles
Browse latest Browse all 9843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>