我正在尝试设置一个Adwords脚本,该脚本会自动发送电子邮件,但是当电子邮件中包含“-”时失败,这会失败

问题描述 投票:0回答:1

我正在尝试设置的脚本使用MailApp服务将电子邮件发送给Ghseet中包含的收件人。

function sendProcessingEmail() {
  var customerId = AdsApp.currentAccount().getCustomerId();
  if (config.emailEachRun && config.emailRecipients &&
      config.emailRecipients.length) {
    MailApp.sendEmail(
        config.emailRecipients.join(','),
        customerId + ': Link Checker: Checking is ongoing',
        'Link checking is still running on account: ' + customerId +
            '. For more details see the spreadsheet: ' +
            CONFIG_SPREADSHEET_URL);
    setDateAsNow('dateEmailed');

我已经注意到,该脚本适用于由数字和字母组成的电子邮件,但是当地址包含其他字符时,则无法发送电子邮件。想知道是否有人知道解决方法吗?提前非常感谢。

javascript google-adwords
1个回答
0
投票

向带有特殊字符在电子邮件地址中]的收件人发送电子邮件没有问题。这个例子很好用:

function main () {
  MailApp.sendEmail('[email protected]', 'test message', 'this works')
}

但是,如果其中一封电子邮件不是有效的电子邮件(例如[email protected],-,[email protected]),则脚本填充失败。在加入之前,请考虑过滤config.emailRecipients以匹配电子邮件模式。可以找到许多可能的正则表达式进行过滤here

© www.soinside.com 2019 - 2024. All rights reserved.