【问题标题】:Google Script not sending email as html谷歌脚本不以 html 格式发送电子邮件
【发布时间】:2014-07-01 20:51:28
【问题描述】:

我设置了一个脚本,用于在新条目提交到共享电子表格时通知用户。我正在尝试以下操作,但电子邮件是以纯文本形式发送的:

function formSubmitReply(e) {
  var emailAddress = ' *email addresses* ';
  var URL = ' *URL to send as link* ';
  var message = "<HTML><BODY>"
   + "<P>" + " A new guest complaint has been entered into the database."
   + '<P>To view the spreadhseet, <A HERF="' + URL + '">click here</A>.'
   + "</HTML></BODY>";

MailApp.sendEmail(emailAddress, "New Guest Complaint", "", {htmlBody: message});
}

有什么建议吗?

【问题讨论】:

    标签: google-apps-script html-email


    【解决方案1】:

    查看官方文档中的示例
    ,其中使用了 htmlBody 参数:https://developers.google.com/apps-script/reference/mail/mail-app#sendEmail(Object) 当参数需要 body html 而不是 html 页面时,您将包含 html 和 body 标签。删除那些标签。另外,请注意最后的标签是颠倒的(/html 然后 /body)

    【讨论】:

    • 谢谢!完美运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-07
    • 2010-11-26
    • 2014-06-22
    相关资源
    最近更新 更多