【发布时间】:2023-03-30 01:55:01
【问题描述】:
问题
我收到自动发送的电子邮件,其中包含特定的客户详细信息。我有重复使用模板回复每封电子邮件的任务。我想利用 Google Apps 脚本自动化该过程。
我在做什么
我已经弄清楚如何收集我正在回复的电子邮件的正文。我正在尝试获取第三段信息并将其存储在变量中。
这是我的代码:
function autoReply() {
//Capturing the automated email
var queryInbox = "is:unread from:(example@gmail.com)";
var locatedEmail = GmailApp.search(queryInbox);
for (var i in locatedEmail){
var thread = locatedEmail[i];
var messages = thread.getMessages();
var msgBody = messages[i].getBody();
var clientsEmail = msgBody.getChild('p')[3]; //Attempting to obtain the third paragraph of the body.
if(messages.length === 1) {
var body = "<p> The clients email is: " + clientsEmail + "</p>";
};
var options = { name: "Temp Name",htmlBody: body };
thread.reply(body, options);
thread.markRead();
thread.moveToArchive();
}
};
注意:附上图片作为上下文。
【问题讨论】:
标签: javascript regex google-apps-script