【问题标题】:Google script mailapp.sendEmail only works with my email addressGoogle 脚本 mailapp.sendEmail 仅适用于我的电子邮件地址
【发布时间】:2013-03-29 04:20:08
【问题描述】:

好吧,这很奇怪。我在电子表格中编写了脚本以从当前活动的工作表中获取信息,使用模板文件创建报告并将其作为附件发送。

当我使用我的 Google Apps 域帐户电子邮件地址作为收件人时,这一切都完美无缺。当我发送到我自己以外的任何其他电子邮件地址时,它不起作用。昨天还在工作。脚本运行时不会产生错误

我唯一做的就是将电子表格的所有者更改为我们域中的另一个用户。在我测试脚本时,它与其他用户共享。我尝试使用我们域中的其他电子邮件地址,并使用 sendemail 功能创建了一个新电子表格,所有这些都具有相同的行为。

// Email the specified report
function emailReport(file, recipients, emailSubject, emailMessage) {
 MailApp.sendEmail("someone@example.com", emailSubject, emailMessage, 
              {attachments: file, mimetype: 'application/pdf'});
}

【问题讨论】:

标签: google-apps-script google-sheets


【解决方案1】:

我已经能够重现该问题并找到解决方法。

由于无法向没有 google 帐户的收件人发送电子邮件,因此我在 cc 字段中添加了此类电子邮件。

// Email the specified report as cc
function emailReport(file, recipients, emailSubject, emailMessage) {
 MailApp.sendEmail("my@gmail.com", emailSubject, emailMessage, 
              {attachments: file, mimetype: 'application/pdf', cc:"someone@example.com"});
}

【讨论】:

    【解决方案2】:

    我不久前注意到了这个问题,甚至在另一个问题中引用了它。从那以后我注意到没有人回复你所以......

    Google 似乎最近更改了 MailApp.sendEmail 函数(尽管在我发现的任何地方都没有记录),因此它仅在您使用属于电子表格所有者的电子邮件地址时才有效。

    我猜这是为了防止系统被用于不请自来的群发电子邮件。

    另一个问题是here

    (抱歉,不是这样的答案:(更多的是对您所看到的内容的确认似乎与预期相符)

    【讨论】:

    • 任何人能够确认这...?
    • 这不是解决问题的办法。
    【解决方案3】:

    对于遇到此问题的任何人,请使用 GmailApp 类而不是 MailApp 类。

    支持相同的功能,例如:GmailApp.sendMail('recipient@gmail.com', 'Subject', 'Message')

    https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String)

    【讨论】:

    • 这并没有解决我的问题,和OP一模一样:只能发邮件到我自己的邮箱。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 2011-12-09
    • 2010-10-22
    相关资源
    最近更新 更多