【问题标题】:Add horizontal line to the Gmail body using Google Scripts使用 Google 脚本向 Gmail 正文添加水平线
【发布时间】:2021-04-02 00:13:47
【问题描述】:

我正在处理从 Google 表单获取的 Google 电子表格中的数据,并且我想向客户发送一封回复电子邮件。这就是我创建 Google 脚本的原因。

是否可以使用 GmailApp.sendEmail(...) 在 Gmail 正文中添加水平线/规则? 类似:

GmailApp.sendEmail('example@gmail.com', 'Title', 'Hello.\n\n[CommandForHR]');

我知道我可以使用'---------'来模拟条,但是我很好奇Google Script中是否存在这样的命令。

搜索

我在 Google Developers webpage 上进行了搜索,但结果是 Google Docs,而不是 Gmail 应用程序。

从上面看,this似乎是我要找的命令,但我不知道如何在GmailApp.sendEmail(...)的参数里面实现。

【问题讨论】:

  • 请按照How to Ask 中的建议添加您的搜索工作的简要说明。
  • @Rubén 谢谢。请查看编辑。
  • 使用 HTML 正文而不是文本正文包含在您的目标中吗?
  • @Tanaike 抱歉,但我不明白你的问题。我想尊重sendEmail 参数的设计语法。所以如果我做对了,我会选择“文本正文”。
  • 如果可以使用HTML正文,可以使用GmailApp.sendEmail("mail address", "sample subject", "sample text body", {htmlBody: "sample text 1<br><hr>sample text 2"});的示例脚本。你也可以测试这个脚本。

标签: google-apps-script gmail horizontal-line


【解决方案1】:

Q1:是否可以使用 GmailApp.sendEmail(...) 在 Gmail 正文中添加水平线/规则?

A1:在这种情况下,当使用 HTML body 时,可以使用<hr> 放置水平线。示例脚本如下。

GmailApp.sendEmail("mail address", "sample subject", "sample text body", {htmlBody: "sample text 1<br><hr>sample text 2"});

Q2:既然您已经找到了 htmlBody,我不再需要 sendEmail 的第三个参数,所以:为了获得正确的语法,我们是否必须将“”写为第三个参数?

A2:如果不使用正文,也可以将上面的脚本修改如下。

GmailApp.sendEmail("mail address", "sample subject", "", {htmlBody: "sample text 1<br><hr>sample text 2"});

或者,您也可以使用MailApp.sendEmail(),如下所示。

MailApp.sendEmail({to: "mail address", subject: "sample subject", htmlBody: "sample text 1<br><hr>sample text 2"});

参考资料:

【讨论】:

    猜你喜欢
    • 2019-09-04
    • 2018-09-17
    • 1970-01-01
    • 2018-09-17
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 2019-03-03
    相关资源
    最近更新 更多