Skip to content

sendEmail function: How to show the account name as sender not the email prefix

I’m sending emails using sendEmail function from google sheets and the emails arrive showing the sender as the prefix of my email address (before the @ sign) instead of my gsuite account name, as they do when sending an email manually. Is there a way to change the from field?

function sendEmail() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet1 = ss.getSheetByName('Sheet1');
  var sheet2 = ss.getSheetByName('Sheet2');
  var subject = sheet2.getRange(2, 1).getValue();
  var n = sheet1.getLastRow();
  for (var i = 2; i < n + 1; i++) {
    var emailAddress = sheet1.getRange(i, 2).getValue();
    var name = sheet1.getRange(i, 1).getValue();
    var message = sheet2.getRange(2, 2).getValue();
    message = message.replace("<name>", name);
    MailApp.sendEmail(emailAddress, subject, message);


When you want to set From of the header from From: to From: sample name <> using MailApp.sendEmail, how about modifying as follows?


MailApp.sendEmail(emailAddress, subject, message);


MailApp.sendEmail(emailAddress, subject, message, {name: "sample name"});


MailApp.sendEmail({to: emailAddress,subject: subject,body: message,name: "sample name"});


  • This modification supposes that your script except for MailApp.sendEmail(emailAddress, subject, message) works.
  • If I misunderstood your goal, can you provide the result value you expect? By this, I would like to confirm it.