简体   繁体   English

谷歌脚本中的发件人姓名

[英]Sender's name in google scripts

I'm following the Google Scripts tutorials on how to send emails from a google sheet.我正在关注有关如何从 Google 表格发送电子邮件的 Google Scripts 教程。

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.如果这对您没有帮助,我很抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用带有完整日期名称的谷歌应用脚本自动滚动电子表格以显示“今天的日期” - Auto Scroll through the spreadsheet to display "today's date" using google app scripts with the full date name 如何从Gmail中获取发件人的姓名? - How can i get the sender's name from a gmail? 使用jmail使用gmail api设置发件人姓名? - Setting sender's name using gmail api with javascript? 创建新的电子表格,以表格 Google Scripts 的名称命名 - Create new spreadsheet name it by the name of sheet Google Scripts 如何修复 Google 应用脚本中的 {"result":"error","error":{"name":"Exception"}} - How to fix {"result":"error","error":{"name":"Exception"}} in google apps scripts Google Scripts,如何将数据设置为具有变量名的工作表 - Google Scripts, how to set data into sheet with variable name Google脚本file.makeCopy(name,destination)无效参数 - google scripts file.makeCopy(name, destination) invalid argument 如何在谷歌脚本中过滤昨天的日期? - How do I filter for yesterday's date in google scripts? 无法通过 Google Scripts 启用 Slack 的“启用事件” - Unable to enable Slack's "Enable Events" through Google Scripts 使用谷歌应用脚本在电子表格中滚动到今天的日期 - Scroll through the spreadsheet to today's date using google app scripts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM