【问题标题】:Sending a canned response with Gmail Apps Script使用 Gmail Apps 脚本发送预设回复
【发布时间】:2018-02-03 16:03:17
【问题描述】:

我正在使用 Google Apps 脚本 (http://script.google.com) 为 gmail 编写一个自动回复工具。

In the docs,我没有找到任何发送 Gmail 的功能预设回复没有这个功能吗?

如果没有,您将如何处理?我想过用 gmail 给自己发一封电子邮件:

To:example@gmail.com
From:example@gmail.com
Subject:This is a canned response ID1847
Hi
This is a test

为其添加标签mycannedresponse,然后在Apps脚本中从代码中加载此邮件:

var threads = GmailApp.search("label:mycannedresponse ID1847");
if (threads.length != 1) { 
    // error: the canned response ID... is not unique
} else {
    threads[0].getBody(...)
    threads[0].getPlainBody(...)
}

有没有更详细的方法可以做到这一点?

【问题讨论】:

  • 并不奇怪:有许多功能可通过 Apps 脚本没有的方法使用。我要么硬编码预设回复,要么将它们存储在一些电子表格中以便于编辑。

标签: javascript google-apps-script gmail gmail-api


【解决方案1】:

你见过 GAS 的 sendEmail 方法吗?您可以创建触发器来触发此电子邮件。

 // The code below will send an email with the current date and time.
var now = new Date();
GmailApp.sendEmail("mike@example.com", "current time", "The time is: " + now.toString());

https://developers.google.com/apps-script/reference/gmail/gmail-app#sendemailrecipient-subject-body

【讨论】:

    猜你喜欢
    • 2016-05-05
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 2019-10-20
    • 2017-01-27
    • 1970-01-01
    • 2020-06-18
    相关资源
    最近更新 更多