【问题标题】:Mailapp.sendEmail control from user来自用户的 Mailapp.sendEmail 控制
【发布时间】:2014-12-13 02:12:20
【问题描述】:

我目前在我的 google 打开工作表脚本中使用此功能...

MailApp.sendEmail(emailAddress,emailAddress, 主题, 正文);

问题是我无法控制发件人电子邮件地址。发件人电子邮件在哪里设置?我可以控制回复电子邮件地址,但这并不能真正解决我的问题。

有什么想法吗? 谢谢!

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    这个问题比较复杂,因为您同时拥有MailApp(您正在使用)和GmailApp(您不是,但可以类似地用于发送邮件)。

    .sendEmail 函数的结构实际上是 .sendEmail(recipient, subject, body, options),其中的选项让您能够修改诸如“发件人”地址。

    对于 MailApp,您无法修改发件人地址,这不是选项之一。推测其原因很简单(垃圾邮件发送者会喜欢允许他们从他们想要的任何电子邮件地址发送邮件的脚本),但毫无意义。

    对于 GmailApp,您可以将您的发件人地址指定为 options 之一,但这仅限于从当前运行脚本的 GMail 帐户中选择别名地址。你可以这样做:

     // Send an email specifying a from address
     GmailApp.sendEmail('mike@example.com', 'Subject example', 'This is the body of the message', {
         from: 'one-of-your-alias-addresses@mydomain.com', //Specify a from address, must be an alias of the sending account
         name: 'John Doe'//Specify my name if I want
     });
    

    注意:使用它需要运行脚本的用户授予我认为的额外权限。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多