简体   繁体   中英

Sender's name in google scripts

I'm following the Google Scripts tutorials on how to send emails from a google sheet.

The code works fine and I do receive an email when I run it. However, when I check my inbox, instead of the header showing my name in the preview, it shows the full email address.

Here's the code from the tutorial:

function sendEmails() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2;  // First row of data to process
  var numRows = 2;   // Number of rows to process
  // Fetch the range of cells A2:B3
  var dataRange = sheet.getRange(startRow, 1, numRows, 2)
  // Fetch values for each row in the Range.
  var data = dataRange.getValues();
  for (i in data) {
    var row = data[i];
    var emailAddress = row[0];  // First column
    var message = row[1];       // Second column
    var subject = "Sending emails from a Spreadsheet";
    MailApp.sendEmail(emailAddress, subject, message);
  }
}

Is there any way I can set it to be my name instead of it being my full email address? 在此处输入图片说明

How about following modification for your script?

From :

MailApp.sendEmail(emailAddress, subject, message);

To :

MailApp.sendEmail(emailAddress, subject, message, {name: '### Your name ###'});

If this was not helpful for you, I'm sorry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM