sendemail的Google AppScript语法错误.无法识别我的问题 [英] Google AppScript syntax error for sendemail. Can't ID my problem

查看:55
本文介绍了sendemail的Google AppScript语法错误.无法识别我的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让Google工作表从工作簿中另一工作表的长列表中发送个性化电子邮件.我使用了一个教程(因为我是所有编码语言的认证新手),但是AppScript告诉我第4行存在语法错误.我无法为自己的一生弄清楚自己做错了什么,但是我敢肯定,当由具有这些合法技能的人解释时,这显然是显而易见的.这是脚本:

I am trying to get Google sheets to send personalized emails from long list on another sheet in the workbook. I used a tutorial (as I am a certified novice at all coding languages) but the AppScript is telling me that line 4 has a syntax error. I cannot for the life of me figure out what I've done wrong, but I'm sure that its blatantly obvious when explained by someone with these legitimate skills. Here is the script:

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);
    }

    }

任何可以帮助我顺利运行的人都是真正的救命稻草!

Anyone that could help me get this running would be a true life saver!

推荐答案

问题中的代码具有''" " (打开/关闭卷曲的单引号和双引号),而不是''(直接的单引号和双引号).将第一个替换为相应的直引号.

The code in the question has , and "," (opening/closing curly single and double quotes) instead of ' and " (straight single and double quote). Replace the first by the corresponding straight quote.

我已经看到,这个问题通常发生在Google Apps脚本的新手身上,他们发现不错"的提示.网站上的一段代码,对于发布代码并不是很友好.该网站很有可能使用的是将直引号替换为印刷引号的内容.

I have seen that this problem usually happens to people new to Google Apps Script that find a "nice" piece of code on a website that isn't really friendly for publishing code. It's very likely the website is using something that replaces straight quotes by the also called typographic quotes.

相关

这篇关于sendemail的Google AppScript语法错误.无法识别我的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆