我有电子邮件地址“ a@gmail.com”,将邮件发送到电子邮件地址“ b@gmail.com”。 我想将邮件回复到电子邮件地址“ a @ gmail”,并添加更多电子邮件地址“ c@gmail.com”。我阅读了google文档,但没有成功。仅接收到电子邮件地址“ a@gmail.com”,而电子邮件地址“ c@gmail.com”尚未收到该邮件。我不知道我在哪里错???感谢您的关注!
function replyToMutiAddress(){
var thread = GmailApp.getThreadById("16dxxxxxxba6");
var mgs = thread.getMessages()[0];
var option = {
replyTo: "a@gmail.com,c@gmail.com",
cc: "",
bcc: "",
htmlBody: "b@gmail.com reply mail to a@gmail.com and add c@gmail.com"
}
mgs.reply("",option);
}
答案 0 :(得分:1)
这个答案怎么样?
The official document of Sending Email如下。
如果您要发送回复并希望发送电子邮件,请确保:
- 主题标题匹配
- References和In-Reply-To标头遵循RFC 2822标准。
对于上述情况,使用Gmail API答复电子邮件。在运行脚本之前,请在Advanced Google services上启用Gmail API。
function replyToMutiAdress(){
var body = "sample body";
var additionalEmailAddress = "c@gmail.com";
var thread = GmailApp.getThreadById("16dxxxxxxba6");
var mgs = thread.getMessages()[0];
var message = Gmail.Users.Messages.get("me", mgs.getId());
var head = 'Content-Type: text/plain; charset="UTF-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: 7bit\r\n';
var data = message.payload.headers.reduce(function(s, e) {
if (e.name.toUpperCase() == "MESSAGE-ID") {
s += "References: " + e.value + "\r\nIn-Reply-To: " + e.value + "\r\n";
} else if (e.name == "Subject") {
s += e.name + ": " + e.value + "\r\n";
} else if (e.name == "From") {
s += "To: " + e.value + "," + additionalEmailAddress + "\r\n";
} else if (e.name == "To") {
s += "From: " + e.value + "\r\n";
}
return s;
}, head);
data += "\r\n" + body;
var res = Gmail.Users.Messages.send({raw: Utilities.base64EncodeWebSafe(data)}, "me");
}
References
和In-Reply-To
。c@gmail.com
被添加为其他电子邮件地址。